Question: Manipulating digits of a given number

Hey folks I need some help with basic string manipulation.


Say I want to find the sum of the digits of 123


What I've been doing is the loooong way of converting 123 to a string, breaking it up into 3 seperate numbers, converting these back to their decimal value, then adding them up.


How could I make this more efficient? Is there some part of StringTools that would do this for me?


Then is there a general way of doing this if you want to do some other operation like say, find the product of the digits of 123, or find the product of the factorial of the digits of 123 for example.


Basically I would like to know how to work with the individual digits of a number in the most efficient way possible...

Please Wait...