U E D R , A S I H C RSS

Reverse And Add/임인택

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>

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2009-05-27 07:09:19
Processing time 0.0082 sec