Reversing Long integers
Ira H. Fuchs
fuchs at princeton.edu
Wed Apr 21 13:35:02 EDT 1999
More information about the Python-list mailing list
Wed Apr 21 13:35:02 EDT 1999
- Previous message (by thread): [ANNOUNCE] Programme final JPF001
- Next message (by thread): Reversing Long integers
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I am attempting to write an efficient Python program which can add an integer to its reverse. This is quite easy to do in Lisp and Mathematica but (mostly out of curiosity) I wanted to see how one might do this in Python. Converting an integer to a string and reversing it and converting back is quite easy (although not all of these ops are primitives) but the fact that Long integers have the letter L appended means that the loop must include moving the L to the end of the reversed string prior to summing. Can anyone think of a particularly clever way to do this?
- Previous message (by thread): [ANNOUNCE] Programme final JPF001
- Next message (by thread): Reversing Long integers
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list