
Thanks to all for your answers!
With "return $!" the program now works "as expected".
Forcing Int, and moving the "let b" in the "else" part, also brings some
(but comparatively far less) improvement.
Note that, as indicated in my initial post, this program is a *modified*
version of "Man or boy", and therefore it does not return the same values.
Best,
Antoine
2017-01-26 14:32 GMT+01:00 Frank Staals
Antoine Rimlet
writes: Hi list,
I try to get the following little program (a slightly modified "Man or boy", it prints -14254067) work "as expected", that is, without consuming lots of memory
Are you sure "-14254067" is correct for k=22? Wikipedia [1] and RosettaCode [2] both seem to suggest that -865 609 is the right answer. Similarly, for k=10 it is supposed to return -67 rather than -577.
[1] https://en.wikipedia.org/wiki/Man_or_boy_test [2] http://rosettacode.org/wiki/Man_or_boy_test
--
- Frank