Project Euler solutions in Javascript and R