No older revisions available
No older revisions available
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>