Connecting Tech Pros Worldwide Forums | Help | Site Map

A Judagrali series: problem.

Newbie
 
Join Date: May 2007
Location: Harare, Zimbabwe
Posts: 8
#1: Oct 18 '07
A Judagrali series:
Find the 4th prime number N such that N=NumberOfDigits(Q) where N is prime AND Q is
prime AND where Q=2p-1 where P is prime.
Example the 1st prime number N is 2, because 2=NumberOfDigits(31) because 2 is prime and
because 31=2^5-1 and because 5 is prime.
We are looking for the 2nd,3rd, 4th prime number N in the Judagrali series as well as its
corresponding Q and P values.
Hints:
1 The 4th N corresponds to a very large M. Take this into account when doing the
calculation.
2 Computational efficiency is important.
3 Object orientation and inheritance MUST be used. i.e. N is a prime, and a subset
(subclass) of Q, Q is also prime and a subset of P which is also prime.
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#2: Oct 18 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by r034802n

A Judagrali series:
Find the 4th prime number N such that N=NumberOfDigits(Q) where N is prime AND Q is
prime AND where Q=2p-1 where P is prime.
Example the 1st prime number N is 2, because 2=NumberOfDigits(31) because 2 is prime and
because 31=25-1 and because 5 is prime.
We are looking for the 2nd,3rd, 4th prime number N in the Judagrali series as well as its
corresponding Q and P values.
Hints:
1 The 4th N corresponds to a very large M. Take this into account when doing the
calculation.
2 Computational efficiency is important.
3 Object orientation and inheritance MUST be used. i.e. N is a prime, and a subset
(subclass) of Q, Q is also prime and a subset of P which is also prime.

Doesn't look right here. You've got

Quote:
because 31=25-1 and because 5 is prime.
That cannot be correct.
Newbie
 
Join Date: May 2007
Location: Harare, Zimbabwe
Posts: 8
#3: Oct 18 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by r035198x

Doesn't look right here. You've got


That cannot be correct.


it is 2 to the power 5 not 25
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#4: Oct 18 '07

re: A Judagrali series: problem.


So Q = (2^p) - 1 ?
Newbie
 
Join Date: May 2007
Location: Harare, Zimbabwe
Posts: 8
#5: Oct 18 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by r035198x

So Q = (2^p) - 1 ?


yes Q = (2^p) - 1 and p is prime. M is also equal to the N I am searching for.
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#6: Oct 18 '07

re: A Judagrali series: problem.


@OP: Who/what is/was "Judagrali"?

kind regards,

Jos
Newbie
 
Join Date: May 2007
Location: Harare, Zimbabwe
Posts: 8
#7: Oct 18 '07

re: A Judagrali series: problem.


[quote=JosAH]@OP: Who/what is/was "Judagrali"?

kind regards,

Jos[/QUOTE


its a name used for the series.
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#8: Oct 18 '07

re: A Judagrali series: problem.


[quote=r034802n]
Quote:

Originally Posted by JosAH

@OP: Who/what is/was "Judagrali"?

kind regards,

Jos[/QUOTE


its a name used for the series.

Is it a new series? I can't find it; not even in Sloane's Mathematical Series
encyclopedia. (or maybe I'm suffering from temporary blindness again ;-)

kind regards,

Jos
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#9: Oct 18 '07

re: A Judagrali series: problem.


Found them:

Expand|Select|Wrap|Line Numbers
  1. p: 5 n: 2 q: 31
  2. p: 7 n: 3 q: 127
  3. p: 61 n: 19 q: 2305843009213693951
  4. p: 521 n: 157 q: 6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151
  5.  
kind regards,

Jos
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#10: Oct 18 '07

re: A Judagrali series: problem.


Are you allowed to use java.math.BigInteger?
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#11: Oct 18 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by JosAH

Found them:

Expand|Select|Wrap|Line Numbers
  1. p: 5 n: 2 q: 31
  2. p: 7 n: 3 q: 127
  3. p: 61 n: 19 q: 2305843009213693951
  4. p: 521 n: 157 q: 6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151
  5.  
kind regards,

Jos

What! Does the J in Jos stand for Judagrali or something?
You obviously didn't count fingers here so we await your secret algorithm.
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#12: Oct 18 '07

re: A Judagrali series: problem.


Argh, the Ns are Mersenne primes ...
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#13: Oct 18 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by r035198x

Argh, the Ns are Mersenne primes ...

Yep, but that doesn't buy you much; you have to find a prime 2^p-1 (p must be
prime as well) *and* its decimal representation must have a prime number of digits.

kind regards,

Jos (<--- aka the Evil Prime Hunter Strikes Again! ;-)
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#14: Oct 18 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by r035198x

What! Does the J in Jos stand for Judagrali or something?
You obviously didn't count fingers here so we await your secret algorithm.

I used my toes as well ;-)

kind regards,

Jos

ps. hint: RPL
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#15: Oct 18 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by JosAH

I used my toes as well ;-)

kind regards,

Jos

ps. hint: RPL

Bah $%##%*!6
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#16: Oct 18 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by r035198x

Bah $%##%*!6

Sorry, that's not valid RPL ;-)

RPL just uses Java's BigInteger so you can implement this in Java as well.

kind regards,

Jos
Newbie
 
Join Date: May 2007
Location: Harare, Zimbabwe
Posts: 8
#17: Oct 18 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by JosAH

Sorry, that's not valid RPL ;-)

RPL just uses Java's BigInteger so you can implement this in Java as well.

kind regards,

Jos


can I please have the algorithm because I want to implement it in java.
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#18: Oct 18 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by r034802n

can I please have the algorithm because I want to implement it in java.

No, we don't give boilerplate code solutions, not in the Forums sections and not
here in this new 'Challenge' section. Give it a try yourself and when you're stuck
post in the Java forum; we can help you but we won't do it for you.

kind regards,

Jos
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#19: Oct 18 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by JosAH

No, we don't give boilerplate code solutions, not in the Forums sections and not
here in this new 'Challenge' section. Give it a try yourself and when you're stuck
post in the Java forum; we can help you but we won't do it for you.

kind regards,

Jos

Gosh I'd just posted my code and then realized I'd be spoon feeding. It's coming up with the values alright but it's also giving some values
like P :23 Q: 8388607 N :7
Edit, here's the output I got when I had my loop from 1 to 100
Expand|Select|Wrap|Line Numbers
  1. P :5 Q: 31  N :2
  2. P :7 Q: 127  N :3
  3. P :23 Q: 8388607  N :7
  4. P :41 Q: 2199023255551  N :13
  5. P :43 Q: 8796093022207  N :13
  6. P :61 Q: 2305843009213693951  N :19
  7.  
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#20: Oct 18 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by r035198x

Gosh I'd just posted my code and then realized I'd be spoon feeding. It's coming up with the values alright but it's also giving some values
like P :23 Q: 8388607 N :7
Edit, here's the output I got when I had my loop from 1 to 100

Expand|Select|Wrap|Line Numbers
  1. P :5 Q: 31  N :2
  2. P :7 Q: 127  N :3
  3. P :23 Q: 8388607  N :7
  4. P :41 Q: 2199023255551  N :13
  5. P :43 Q: 8796093022207  N :13
  6. P :61 Q: 2305843009213693951  N :19
  7.  

8388607 = 47 * 178481
2199023255551 = 13367 * 164511353

iow: they're not primes, iow: your primality testing method stinks ;-)

kind regards,

Jos
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#21: Oct 18 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by JosAH

8388607 = 47 * 178481
2199023255551 = 13367 * 164511353

iow: they're not primes, iow: your primality testing method stinks ;-)

kind regards,

Jos

So much for BigInteger's isProbablePrime method with Integer.MAX_VALUE as argument.
Better right my own test prime method then.
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#22: Oct 18 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by r035198x

So much for BigInteger's isProbablePrime method with Integer.MAX_VALUE as argument.
Better right my own test prime method then.

Nah, isProbablePrime works perfectly.
I was simply not testing for P being prime as well.
I should defenestrate myself ...
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#23: Oct 18 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by r035198x

Nah, isProbablePrime works perfectly.
I was simply not testing for P being prime as well.
I should defenestrate myself ...

All values of 'p' in your results were primes allright; 'q' wasn't prime. w.r.t. to that
defenestration: please wait 'till I got all the cars out of the way and have informed
the hungry plebeians. ;-)

kind regards,

Jos
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#24: Oct 21 '07

re: A Judagrali series: problem.


According to reply #17 the OP wants Java source code. r035198x and I have had
a little fun with this question and didn't supply any source code because this
question was originally asked in the "Challenges" forum.

kind regards,

Jos
Member
 
Join Date: Oct 2007
Posts: 52
#25: Oct 26 '07

re: A Judagrali series: problem.


then we rather not learn anything from you... then suply the sedo code I my self will do it with java, one more question is did you use long or BigIntegers?
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#26: Oct 26 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by samido

then we rather not learn anything from you... then suply the sedo code I my self will do it with java, one more question is did you use long or BigIntegers?

We used BigInteger alright. First setup your relationship between P and Q
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#27: Oct 26 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by samido

then we rather not learn anything from you... then suply the sedo code I my self will do it with java, one more question is did you use long or BigIntegers?

Well then: don't learn; there is hardly any pseudo code involved:

1) Q == 2^P-1 where both P and Q should be prime
2) (""+Q).length() should also be a prime.

Those are the rules stated by the OP, I simply used a loop over P.

kind regards,

Jos
RedSon's Avatar
Site Moderator
 
Join Date: Jan 2007
Location: America
Posts: 3,393
#28: Oct 26 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by JosAH

According to reply #17 the OP wants Java source code. r035198x and I have had
a little fun with this question and didn't supply any source code because this
question was originally asked in the "Challenges" forum.

kind regards,

Jos

Guys,

I'm a bit confused, isn't the purpose of the challenges forum to post solutions that you have found to a challenge, and then challenge others to try to solve the same problem in a bigger, faster, better manner and then post their solution, which in turn challenges others to solve it again with a better solution, etc., etc.?

And also to collaborate on said solutions?
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#29: Oct 27 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by RedSon

Guys,

I'm a bit confused, isn't the purpose of the challenges forum to post solutions that you have found to a challenge, and then challenge others to try to solve the same problem in a bigger, faster, better manner and then post their solution, which in turn challenges others to solve it again with a better solution, etc., etc.?

And also to collaborate on said solutions?

I was very willing to explain how I did it (and r035198x as well I think), unitl the
OP started begging for boilerplate code and algorithms; that was the show
stopper and I moved the thread to this forum because the OP wanted it in Java.

kind regards,

Jos

ps. it's not much of an algorithm: just search in a 'clever' (mind the quotes) way,
so that you don't have to search too much ;-) And yes you need BigIntegers for it.
Newbie
 
Join Date: Oct 2007
Posts: 1
#30: Oct 30 '07

re: A Judagrali series: problem.


Ive been introduced to this forum by looking up this problem, was given as a question to secure a job interview ... that perhaps explains the guys so desperate for source code ;) lol

The joy of solving stuff like this is figuring it out for yourself! (with tips of course). The inheritance requirement is what first confused me... but when it becomes clear.. its a very nice light bulb moment.

What are the roots of this problem/algo' ? Ive really enjoyed working on it, would just like some history ....
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#31: Oct 30 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by nic777

Ive been introduced to this forum by looking up this problem, was given as a question to secure a job interview ... that perhaps explains the guys so desperate for source code ;) lol

The joy of solving stuff like this is figuring it out for yourself! (with tips of course). The inheritance requirement is what first confused me... but when it becomes clear.. its a very nice light bulb moment.

What are the roots of this problem/algo' ? Ive really enjoyed working on it, would just like some history ....

I have no idea who/what Judagrali is/are.
Initially google didn't return anything when I serached for it but now it crops up this page.
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#32: Oct 30 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by r035198x

I have no idea who/what Judagrali is/are.
Initially google didn't return anything when I serached for it but now it crops up this page.

There are a few databases online that contain 'mathematical series'; some of the
series are extremely weird, but none of those databases contain the Judagrali
series. It's the prime number of digits of number Q that is unique to this series
(not very interesting though).

kind regards,

Jos
Newbie
 
Join Date: Nov 2007
Posts: 1
#33: Nov 22 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by r035198x

Are you allowed to use java.math.BigInteger?

I've been trying to find the code to find the 4th prime number with this Judigrali series but no luck plz help :-)
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#34: Nov 22 '07

re: A Judagrali series: problem.


Quote:

Originally Posted by bathabzo

I've been trying to find the code to find the 4th prime number with this Judigrali series but no luck plz help :-)

Post the code you have tried
Reply


Similar Java bytes