code

~cpp
module ReverseAndAdd
	where

reverseAndAdd number = reverseAndAddSub 0 number

reverseAndAddSub count number = 
	if (show number) == (reverse (show number))
		then [count, number]
		else reverseAndAddSub (count+1) (number + (read (reverse (show number))) )

example

~cpp
ReverseAndAdd> reverseAndAdd 195
[4,9339]
ReverseAndAdd> reverseAndAdd 265
[5,45254]
ReverseAndAdd> reverseAndAdd 750
[3,6666]
ReverseAndAdd>

Retrieved from http://wiki.zeropage.org/wiki.php/ReverseAndAdd/임인택
last modified 2021-02-07 05:27:54