I used python programming and am getting right answer for N <=13 and also the below 4 numbers are giving me the correct numbers.
9993: 94
9994: 70
9995: 4
9996: 4
9997: 59
So, i assume my logic is correct and i guess my incrementing stuff is going wrong . Bcoz PE is showing my answer as incorrect.
Just to add clarity of what i did .
<algorithm removed by moderator>
But, my final answer is not correct. Not sure why . Is there any flaw in my approach ?
Problem 064
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.
- mpiotte
- Administrator
- Posts: 1961
- Joined: Tue May 08, 2012 5:40 pm
- Location: Montréal, Canada
Re: Problem 064
It is inappropriate to post your algorithm here, whether or not it works.srinathmkce wrote:...But, my final answer is not correct. Not sure why . Is there any flaw in my approach ?
If you send me a PM with the period length that you find for the different values of n, I'll compare it with my own list.

-
Omri_Shavit
- Posts: 2
- Joined: Fri Mar 30, 2018 8:32 am
Problem 64: what am I doing wrong?
Hi,
When doing problem 64, Odd period square roots, I got the incorrect answer XXX. So, I began manually checking some of the continued fractions that my code spat out with www.wolframalpha.com. Oddly enough (no pun intended), I couldn't find any that were wrong, and I also couldn't find any whose period was labeled even/odd incorrectly either. Please help.
P.S. I'll PM you a text file of what my code outputs (don't know if I should post it here b/c spoilers):
It looks like this:
x: sqrt(x): period length: current # of odds:
1 --> 1 --> DNE (rational) --> 0
2 --> [1;(2)] --> 1 = odd (+) --> 1
3 --> [1;(1,2)] --> 2 = even --> 1
4 --> 2 --> DNE (rational) --> 1
5 --> [2;(4)] --> 1 = odd (+) --> 2
6 --> [2;(2,4)] --> 2 = even --> 2
7 --> [2;(1,1,1,4)] --> 4 = even --> 2
8 --> [2;(1,4)] --> 2 = even --> 2
9 --> 3 --> DNE (rational) --> 2
10 --> [3;(6)] --> 1 = odd (+) --> 3
11 --> [3;(3,6)] --> 2 = even --> 3
12 --> [3;(2,6)] --> 2 = even --> 3
13 --> [3;(1,1,1,1,6)] --> 5 = odd (+) --> 4
...
Later values removed by moderator.
as you can see, somewhere it gets it wrong :/
When doing problem 64, Odd period square roots, I got the incorrect answer XXX. So, I began manually checking some of the continued fractions that my code spat out with www.wolframalpha.com. Oddly enough (no pun intended), I couldn't find any that were wrong, and I also couldn't find any whose period was labeled even/odd incorrectly either. Please help.
P.S. I'll PM you a text file of what my code outputs (don't know if I should post it here b/c spoilers):
It looks like this:
x: sqrt(x): period length: current # of odds:
1 --> 1 --> DNE (rational) --> 0
2 --> [1;(2)] --> 1 = odd (+) --> 1
3 --> [1;(1,2)] --> 2 = even --> 1
4 --> 2 --> DNE (rational) --> 1
5 --> [2;(4)] --> 1 = odd (+) --> 2
6 --> [2;(2,4)] --> 2 = even --> 2
7 --> [2;(1,1,1,4)] --> 4 = even --> 2
8 --> [2;(1,4)] --> 2 = even --> 2
9 --> 3 --> DNE (rational) --> 2
10 --> [3;(6)] --> 1 = odd (+) --> 3
11 --> [3;(3,6)] --> 2 = even --> 3
12 --> [3;(2,6)] --> 2 = even --> 3
13 --> [3;(1,1,1,1,6)] --> 5 = odd (+) --> 4
...
Later values removed by moderator.
as you can see, somewhere it gets it wrong :/
Last edited by RobertStanforth on Wed Apr 18, 2018 7:20 pm, edited 1 time in total.
Reason: Removed partial answers
Reason: Removed partial answers
- RobertStanforth
- Administrator
- Posts: 2666
- Joined: Mon Dec 30, 2013 11:25 pm
Re: Problem 064
Dear Omri_Shavit,
I moved your post to the existing clarification thread for this problem.
Based on your workings for the first 13 cases, you understand the problem statement correctly.
Moreover, the continued fraction you provided for 9999 was correct - but your overall answer was much too low.
I moved your post to the existing clarification thread for this problem.
Based on your workings for the first 13 cases, you understand the problem statement correctly.
Moreover, the continued fraction you provided for 9999 was correct - but your overall answer was much too low.
-
Omri_Shavit
- Posts: 2
- Joined: Fri Mar 30, 2018 8:32 am
Re: Problem 064
Dear RobertStanforth,
Thank you for replying. I finally got it! My mistake was embarrassingly simple: I originally capped the algorithm at 30 iterations for testing purposes (so it would not go on forever if I was doing something wrong). Once I got the algorithm working, I neglected to remove the 30-iteration limit which resulted in it setting every period greater than 30 to 30 --> even. That's why many odd-period fractions were not counted.
Thanks again,
Omri Shavit
Thank you for replying. I finally got it! My mistake was embarrassingly simple: I originally capped the algorithm at 30 iterations for testing purposes (so it would not go on forever if I was doing something wrong). Once I got the algorithm working, I neglected to remove the 30-iteration limit which resulted in it setting every period greater than 30 to 30 --> even. That's why many odd-period fractions were not counted.
Thanks again,
Omri Shavit