RosettaCodeData/Task/Hailstone-sequence/Prolog/hailstone-sequence-1.pro
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

3 lines
162 B
Prolog

hailstone(1,[1]) :- !.
hailstone(N,[N|S]) :- 0 is N mod 2, N1 is N / 2, hailstone(N1,S).
hailstone(N,[N|S]) :- 1 is N mod 2, N1 is (3 * N) + 1, hailstone(N1, S).