View Single Post
Old 2017-03-02, 18:05   #4
fivemack
(loop (#_fork))
 
fivemack's Avatar
 
Feb 2006
Cambridge, England

22·1,613 Posts
Default

Quote:
Originally Posted by EdH View Post
In my do-while loop, I'm simply advancing the lower series by square differences and once the value has surpassed the high square, I advance the high square to the next square. The difference swings above and below 0, until at some point it equals 0
You don't need the lower series - you just need to advance the high series until the difference is _some_ square, and checking whether a number is a square isn't too difficult. If a number is a possible-square-mod-p for lots of p, it's pretty likely to be square, and each p rules out about half the numbers ... you can keep track of the values of the high series modulo lots of p quite efficiently since you're only doing addition.
fivemack is offline   Reply With Quote