how do I factor a number down to one digit?

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Mon Feb 27 05:51:05 EST 2006


Allan>I hope this isn't too stupid of a question.

It's a simple problem, but it's not a stupid question, this is a
possible solution:

data = "myname"
radix = str(sum(ord(c)-96 for c in data))
while len(radix) > 1:
    radix = str(sum(int(c) for c in radix))
print "The radix of:\n", data, "\n\nIs:\n", radix

Bye,
bearophile




More information about the Python-list mailing list