Originally Posted by Rhaethe
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.