Problem 123
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.
-
jotd
- Posts: 4
- Joined: Wed Feb 16, 2011 5:26 pm
Problem 123
Hi,
This seems pretty straightforward, and I can verify the value given by the problem for 10**9 (7037) in less than a second.
However, my answer to the question for 10**10 (obtained in a second too) is wrong, whereas I use exactly the same computation. Anyone confirms this? Is there a problem in the value of the expected solution?
thanks
This seems pretty straightforward, and I can verify the value given by the problem for 10**9 (7037) in less than a second.
However, my answer to the question for 10**10 (obtained in a second too) is wrong, whereas I use exactly the same computation. Anyone confirms this? Is there a problem in the value of the expected solution?
thanks
- hk
- Administrator
- Posts: 12831
- Joined: Sun Mar 26, 2006 10:34 am
- Location: Haren, Netherlands
-
dgriff
- Posts: 1
- Joined: Thu Feb 24, 2011 4:35 am
- Location: College Station, Texas
Re: Problem 123
In the problem, Pn is the nth prime, so P1 = 2
Your program probably says that P0 = 2
At least that's what my problem was. The problem isn't worded in the most programmer-friendly way.
Your program probably says that P0 = 2
At least that's what my problem was. The problem isn't worded in the most programmer-friendly way.

-
jotd
- Posts: 4
- Joined: Wed Feb 16, 2011 5:26 pm
Re: Problem 123
you are right! but with 10**9 I get the 7037 something result. So the problem wording is wrong BTW
And adding 1 to my result still is not accepted
Adding 2 works
thanks
And adding 1 to my result still is not accepted
Adding 2 works
thanks
- GenePeer
- Posts: 112
- Joined: Sat Apr 03, 2010 1:14 pm
- Contact:
Re: Problem 123
I think the problem is your program. Maybe it's exiting the loop before updating the value of n. Since n is always odd, the "margin of error" is 2 instead of the usual 1. My program gave the right answer without modifications.jotd wrote:you are right! but with 10**9 I get the 7037 something result. So the problem wording is wrong BTW
And adding 1 to my result still is not accepted
Adding 2 works
thanks

-
rblackadar
- Posts: 4
- Joined: Wed May 29, 2013 5:09 pm
Re: Problem 123
The more likely explanation is that, because of the off-by-one index, he used the correct exponent n but the incorrect prime pn+1 in the equation. That mixed equation happens to give a "good" result for 10**9, but only by accident. By the way, a careful reading of the problem makes the indexing unambiguous.GenePeer wrote:I think the problem is your program. Maybe it's exiting the loop before updating the value of n. Since n is always odd, the "margin of error" is 2 instead of the usual 1. My program gave the right answer without modifications.jotd wrote:you are right! but with 10**9 I get the 7037 something result. So the problem wording is wrong BTW
And adding 1 to my result still is not accepted
Adding 2 works
thanks
- Oliver1978
- Posts: 166
- Joined: Sat Nov 22, 2014 9:13 pm
- Location: Erfurt, Germany
Re: Problem 123
So, to straighten things out... if n=1 then p_n=2, if n=2 then p_n=3 et cetera and finally if n=7037 then p_n=71059.
Right?
Right?
49.157.5694.1125
- dawghaus4
- Posts: 56
- Joined: Fri Nov 29, 2013 2:22 am
Re: Problem 123
Since p_n is your own notation, it might be of help, if you define its meaning.leghorn wrote:So, to straighten things out... if n=1 then p_n=2, if n=2 then p_n=3 et cetera and finally if n=7037 then p_n=71059.
Right?
It appears that p_n means the nth prime and the 1st prime is 2, the 2nd prime is 3 and the 7037th prime is 71059.
Tom
- Oliver1978
- Posts: 166
- Joined: Sat Nov 22, 2014 9:13 pm
- Location: Erfurt, Germany
Re: Problem 123
Thanks, dawg. That's what I meant, like in the problem's description: p_n denotes the nth prime.
[edit]
Could anybody check out n = 6544 (pn = 65539)? Using the formula ((pn-1)^n + (pn+1)^n) mod pn^2 gives a remainder of 3,780,539,272. Using the test case I never get to 7037
[another edit]
Could it be that this is overflowing on 64 bit already?
[edit]
Could anybody check out n = 6544 (pn = 65539)? Using the formula ((pn-1)^n + (pn+1)^n) mod pn^2 gives a remainder of 3,780,539,272. Using the test case I never get to 7037
[another edit]
Could it be that this is overflowing on 64 bit already?
49.157.5694.1125
- Oliver1978
- Posts: 166
- Joined: Sat Nov 22, 2014 9:13 pm
- Location: Erfurt, Germany
-
kkm000
- Posts: 3
- Joined: Mon Oct 18, 2021 12:16 am
Re: Problem 123
original message
Sorry. The first prime is 2. It's just me. I'm an idiot tonight. 🤪
Expand
