[Tutor] OverflowError in lucky numbers script

Marc Tompkins marc.tompkins at gmail.com
Mon Jan 23 20:42:08 CET 2012


On Mon, Jan 23, 2012 at 10:51 AM, Shreesh bhat <shreeshbhat90 at gmail.com>wrote:

> I have given the definition of lucky numbers and constraints involved at
> the starting of the thread.
> when a number's sum of digits and square of sum of digits is prime,it is
> called lucky.
>

Just to clarify: do you mean "(sum of digits) + (sum of digits)^2"?
If so, the ONLY lucky numbers are those whose digits add up to 1... because
"x + x^2" is always even (for real integers), and 2 is the only even prime
number.
So, if I understood your definition, here are the lucky numbers up to 10^18:
1
10
100
1000
...
10000000000000000
100000000000000000
1000000000000000000

It seems to me that the problem can't possibly be that simple, so I must
have misunderstood your definition.  Please explain!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120123/5b10e0d5/attachment.html>


More information about the Tutor mailing list