# flipping number question..

• 12-08-2008
transgalactic2
flipping number question..
what is the math formula(algorithm) for flipping any number like:
47->74
1655 -> 5561

12345->54321

1190 -> 911

??
• 12-08-2008
itCbitC
Use a for loop and divide the number by 10 in each iteration till it's zero while accruing the remainder, which is printed out after the loop is finished. Just my 2c and others may have better ways.
• 12-08-2008
MK27
Quote:

Originally Posted by itCbitC
Use a for loop and divide the number by 10 in each iteration till it's zero while accruing the remainder, which is printed out after the loop is finished. Just my 2c and others may have better ways.

Wow itCbitC
• 12-08-2008
dwks
If you want an actual number that you can use, you could use something like this:
Code:

```newnum = 0 for each digit in number:     digit = number &#37; 10     newnum = newnum * 10 + digit```
If all you want to do is reverse the data, you could do as itCbitC suggested, or, if you have a string representation of the number, you could just print the string in reverse. :)
• 12-09-2008
transgalactic2
solved it thanks :)