ShareMyScreen/ProjectEuler/0005

From J Wiki
Jump to navigation Jump to search

The problem can be described as LCM(LCM(LCM(1, 2), ...), 20), which finds the answer progressively. J has a primitive for computing the LCM of two numbers *. and can be inserted between each item in the range 1 to 20 using /.

   *./ 1 + i.10   NB. confirm with the example
2520
   *./ 1 + i.20   NB. the answer
232792560