Hacker News new | past | comments | ask | show | jobs | submit login

Reminds me of the time I was trying the first problem of Project Euler, “Multiples of 3 and 5” in Joy.

https://projecteuler.net/problem=1

> If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

> Find the sum of all the multiples of 3 or 5 below 1000.

I tried dual iterators at first but it turned out to be more elegant to just generate the multiples directly using the sequence:

    3 2 1 3 1 2 3
It turn out that the differences between successive multiples always form a palindrome.

http://joypy.osdn.io/notebooks/Developing.html

(In re: catamorphism et. al. see http://joypy.osdn.io/notebooks/Recursion_Combinators.html Cheers!)




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: