Problem 134
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.
This forum is NOT meant to discuss solution methods for a problem.
In particular don't post any code fragments or results.
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
Don't start begging others to give partial answers to problems
Don't ask for hints how to solve a problem
Don't start a new topic for a problem if there already exists one
See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
-
Bhilal
- Posts: 12
- Joined: Sat Sep 27, 2008 9:50 am
Problem 134
for the i < 100 i found these answers
5 7 35
7 11 77
11 13 611
13 17 1513
17 19 817
19 23 1219
23 29 2523
29 31 1829
31 37 2331
37 41 2337
41 43 3741
43 47 3243
47 53 5247
53 59 3953
59 61 1159
61 67 5561
67 71 5467
71 73 1971
73 79 6873
79 83 1079
83 89 4183
89 97 3589
sum 59358
when i generalize it i found an answer which seem incorrect. Can you give me any " sum " up to the any i?
for example what is the sum 5 <= i <= 1000 and 40000 <= i <= 92000 and other. Because it will help to find the correct answer.
Thanks in advance
5 7 35
7 11 77
11 13 611
13 17 1513
17 19 817
19 23 1219
23 29 2523
29 31 1829
31 37 2331
37 41 2337
41 43 3741
43 47 3243
47 53 5247
53 59 3953
59 61 1159
61 67 5561
67 71 5467
71 73 1971
73 79 6873
79 83 1079
83 89 4183
89 97 3589
sum 59358
when i generalize it i found an answer which seem incorrect. Can you give me any " sum " up to the any i?
for example what is the sum 5 <= i <= 1000 and 40000 <= i <= 92000 and other. Because it will help to find the correct answer.
Thanks in advance
- hk
- Administrator
- Posts: 12832
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: pe 134
sum 5<=i<=100 is 69155

War ruins the life and health of untold numbers of innocent children.
-
Bhilal
- Posts: 12
- Joined: Sat Sep 27, 2008 9:50 am
Re: pe 134
Code: Select all
public static long primevu(int i, int j)
{
String s = Integer.toString(i);
for(long k=2; k<10000000L; k++)
{
long a = j*k;
if(Long.toString(a).endsWith(s))
return a;
}
return 0;
}
- daniel.is.fischer
- Posts: 2400
- Joined: Sun Sep 02, 2007 11:15 pm
- Location: Bremen, Germany
Re: pe 134
I'm pretty sure it's just a misreading of the problem statement: "for every pair of consecutive primes with 5 ≤ p1 ≤ 1000000", see it?
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
-
Bhilal
- Posts: 12
- Joined: Sat Sep 27, 2008 9:50 am
Re: pe 134
unfortunately no
what i understand is finding small n for every consecutive primes (5, 7) n1, (7,11) n2, ... and adding them up.
- Tommy137
- Posts: 238
- Joined: Sun Feb 24, 2008 6:02 pm
- Location: Cologne, Germany
- Contact:
Re: pe 134
Right... and 5 ≤ p1 ≤ 1000000 as daniel said. There you're overlooking somethingBhilal wrote:unfortunately nowhat i understand is finding small n for every consecutive primes (5, 7) n1, (7,11) n2, ... and adding them up.

-
Bhilal
- Posts: 12
- Joined: Sat Sep 27, 2008 9:50 am
Re: pe 134
If so what is the mistake for the 5<=i<=100 sum = 59358? Now 3.09 night in my country
i try to find the answer then do my programming homework then sleep
Please help me to correct my mistake
- daniel.is.fischer
- Posts: 2400
- Joined: Sun Sep 02, 2007 11:15 pm
- Location: Bremen, Germany
Re: pe 134
Look at the difference of your result and the one hk gave. That might show you what you've been missing.
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
-
Bhilal
- Posts: 12
- Joined: Sat Sep 27, 2008 9:50 am
-
Bhilal
- Posts: 12
- Joined: Sat Sep 27, 2008 9:50 am
Re: pe 134
i found. thanks my friend
. Now i am starting to fight with tree and file algorithms
to sunrise
-
olleicua
- Posts: 8
- Joined: Fri Oct 07, 2011 5:00 am
Re: Problem 134
I'm confused by the problem statement. It says "Consider the consecutive primes p1 = 19 and p2 = 23. It can be verified that 1219 is the smallest number such that the last digits are formed by p1 whilst also being divisible by p2."
Isn't 35 a counterexample. 5 and 7 are consecutive primes and and 35 ends in 5 and is divisible by 7. What am I missing here?
Isn't 35 a counterexample. 5 and 7 are consecutive primes and and 35 ends in 5 and is divisible by 7. What am I missing here?
-
TripleM
- Posts: 384
- Joined: Fri Sep 12, 2008 3:31 am
Re: Problem 134
1219 is the smallest number that ends in 19 and is divisible by 23. 35 is the smallest number that ends in 5 and is divisible by 7. There's no contradiction there.
-
Mathmannix
- Posts: 3
- Joined: Tue May 01, 2012 2:45 pm
Re: Problem 134
Are these results correct?
for p in [5,100], sum(S) = 9,797
for p in [5,1E3], sum(S) = 36,941,222
for p in [5,1E4], sum(S) = 27,951,351,491
for p in [5,1E5], sum(S) = 22,415,801,611,632
???
I ask because (a) my program is taking more than 20 minutes to find the sum for p in [5,1E6],
and (b) because it seems that the answer will be a 17-digit number (or so), which seems unlikely for us to have to input in the answer box.
for p in [5,100], sum(S) = 9,797
for p in [5,1E3], sum(S) = 36,941,222
for p in [5,1E4], sum(S) = 27,951,351,491
for p in [5,1E5], sum(S) = 22,415,801,611,632
???
I ask because (a) my program is taking more than 20 minutes to find the sum for p in [5,1E6],
and (b) because it seems that the answer will be a 17-digit number (or so), which seems unlikely for us to have to input in the answer box.
- hk
- Administrator
- Posts: 12832
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: Problem 134
If your program would take 20 minutes you could either
1)let it run and use the PE answer checker to verify your result
2)try to make a faster one.
Moreover, why should a 17 (or so) digit answer be unlikely?
1)let it run and use the PE answer checker to verify your result
2)try to make a faster one.
Moreover, why should a 17 (or so) digit answer be unlikely?

War ruins the life and health of untold numbers of innocent children.
-
thundre
- Posts: 356
- Joined: Sun Mar 27, 2011 10:01 am
Re: Problem 134
I think all of those numbers are correct except the first. I don't know how your algorithm can be right for 1000 but wrong for 100.
Most PE answers fit in a 64-bit signed integer, which can have up to 19 digits, or a 64-bit floating point, in which case the problem states how many digits after the decimal to round to.
Most PE answers fit in a 64-bit signed integer, which can have up to 19 digits, or a 64-bit floating point, in which case the problem states how many digits after the decimal to round to.

- hk
- Administrator
- Posts: 12832
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
Re: Problem 134
The PE team don't consider themselves restricted to what you write down here wrt the answer format.thundre wrote:
Most PE answers fit in a 64-bit signed integer, which can have up to 19 digits, or a 64-bit floating point, in which case the problem states how many digits after the decimal to round to.
I think you're mixing up computational restrictions with answer format restrictions.

War ruins the life and health of untold numbers of innocent children.
-
thundre
- Posts: 356
- Joined: Sun Mar 27, 2011 10:01 am
Re: Problem 134
Of course there are answer formats I didn't even mention. IIRC, at least one problem requires a fraction with a slash between the numerator and denominator. And I realize the "rules" that the team applies to computation algorithms don't necessarily apply to final answers.hk wrote:The PE team don't consider themselves restricted to what you write down here wrt the answer format.
I think you're mixing up computational restrictions with answer format restrictions.
I'm just saying that simply having 17 digits is not a reason to doubt an answer. But having 20 digits might be. And if the problem specifies 10 digits to the right of the decimal, but my answer is greater than 106, that value exceeds the 53-bit precision of the double mantissa, which would also be a red flag indicating I'm probably wrong.

-
iarribas
- Posts: 1
- Joined: Tue Nov 27, 2012 3:54 pm
Re: Problem 134
I tray again and again but unsuccessfully. My code works for p in 5-10^5 (it coincides with the results given by Mathmannix (Thu Aug 09, 2012 4:22 pm), but when I tray for p in 5-10^6 it fails.
I’ll appreciate any help or suggestion. Any clue I could be forgetting.
I’ll appreciate any help or suggestion. Any clue I could be forgetting.