Thread: Count to 1,000!
View Single Post
09-01-09, 01:31 PM   #229
Vyper
A Rage Talon Dragon Guard
 
Vyper's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 317
Originally Posted by Rhaethe View Post
The 196-algorithm: Take any number. Reverse its digits, then add both numbers together. If the result is not a palindrome (reads backwards and forwards), repeat the process.
Result of running the algorithm as specified on 202:
404
(you really should be checking to see if you're starting with a palindrome )


Edit: A quit ruby script verifies that this algorithm does not work for 196
Code:
str=''
print 'enter your number: '
str=gets
while str != str.reverse
        puts str
        str=(str.to_i+str.reverse.to_i).to_s
end
puts str
This loops until I get impatient and kill it.

Edit 2: Oh hey, if you read up on it, it's named the 196 algorithm because it fails to produce a result for 196.

Last edited by Vyper : 09-01-09 at 01:47 PM.
  Reply With Quote