A Judagrali series: problem. | Newbie | | Join Date: May 2007 Location: Harare, Zimbabwe
Posts: 8
| | |
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
| | | 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
| | | 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
| | | re: A Judagrali series: problem.
So Q = (2^p) - 1 ?
| | Newbie | | Join Date: May 2007 Location: Harare, Zimbabwe
Posts: 8
| | | 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.
|  | Expert | | Join Date: Mar 2007
Posts: 10,611
| | | re: A Judagrali series: problem.
@OP: Who/what is/was "Judagrali"?
kind regards,
Jos
| | Newbie | | Join Date: May 2007 Location: Harare, Zimbabwe
Posts: 8
| | | re: A Judagrali series: problem.
[quote=JosAH]@OP: Who/what is/was "Judagrali"?
kind regards,
Jos[/QUOTE
its a name used for the series.
|  | Expert | | Join Date: Mar 2007
Posts: 10,611
| | | 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
|  | Expert | | Join Date: Mar 2007
Posts: 10,611
| | | re: A Judagrali series: problem.
Found them: -
p: 5 n: 2 q: 31
-
p: 7 n: 3 q: 127
-
p: 61 n: 19 q: 2305843009213693951
-
p: 521 n: 157 q: 6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151
-
kind regards,
Jos
| | Lives Here | | Join Date: Sep 2006
Posts: 12,070
| | | re: A Judagrali series: problem.
Are you allowed to use java.math.BigInteger?
| | Lives Here | | Join Date: Sep 2006
Posts: 12,070
| | | re: A Judagrali series: problem. Quote:
Originally Posted by JosAH Found them: -
p: 5 n: 2 q: 31
-
p: 7 n: 3 q: 127
-
p: 61 n: 19 q: 2305843009213693951
-
p: 521 n: 157 q: 6864797660130609714981900799081393217269435300143305409394463459185543183397656052122559640661454554977296311391480858037121987999716643812574028291115057151
-
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
| | | re: A Judagrali series: problem.
Argh, the Ns are Mersenne primes ...
|  | Expert | | Join Date: Mar 2007
Posts: 10,611
| | | 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! ;-)
|  | Expert | | Join Date: Mar 2007
Posts: 10,611
| | | 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
| | | re: A Judagrali series: problem. Quote:
Originally Posted by JosAH I used my toes as well ;-)
kind regards,
Jos
ps. hint: RPL Bah $%##%*!6
|  | Expert | | Join Date: Mar 2007
Posts: 10,611
| | | 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
| | | 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.
|  | Expert | | Join Date: Mar 2007
Posts: 10,611
| | | 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
| | | 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 - P :5 Q: 31 N :2
-
P :7 Q: 127 N :3
-
P :23 Q: 8388607 N :7
-
P :41 Q: 2199023255551 N :13
-
P :43 Q: 8796093022207 N :13
-
P :61 Q: 2305843009213693951 N :19
-
|  | Expert | | Join Date: Mar 2007
Posts: 10,611
| | | 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 - P :5 Q: 31 N :2
-
P :7 Q: 127 N :3
-
P :23 Q: 8388607 N :7
-
P :41 Q: 2199023255551 N :13
-
P :43 Q: 8796093022207 N :13
-
P :61 Q: 2305843009213693951 N :19
-
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
| | | 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
| | | 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 ...
|  | Expert | | Join Date: Mar 2007
Posts: 10,611
| | | 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
|  | Expert | | Join Date: Mar 2007
Posts: 10,611
| | | 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
| | | 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
| | | 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
|  | Expert | | Join Date: Mar 2007
Posts: 10,611
| | | 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
|  | Site Moderator | | Join Date: Jan 2007 Location: America
Posts: 3,393
| | | 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?
|  | Expert | | Join Date: Mar 2007
Posts: 10,611
| | | 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
| | | 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
| | | 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.
|  | Expert | | Join Date: Mar 2007
Posts: 10,611
| | | 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
| | | 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
| | | 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
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,387 network members.
|