1 min read

APL Hacking: Project Euler Daily (#5)

I really do not like my solution here, but it was the simplest at the time. I think that there is definitely a neater way to do this one:

Problem #5:

R←PEFIVE

⍝ What is tthe smallest positive number that is evenly divisible
⍝ by all of the numbers from 1 to 20?

⍝ Prime factorizations

X← 2 0 0 0 0 0 0 0 0 0 0 0 0 ⍝ 2
X←X,0 0 0 0 3 0 0 0 0 0 0 0 0 ⍝ 3
X←X,2 2 0 0 0 0 0 0 0 0 0 0 0 ⍝ 4
X←X,0 0 0 0 0 0 0 5 0 0 0 0 0 ⍝ 5
X←X,2 0 0 0 3 0 0 0 0 0 0 0 0 ⍝ 6
X←X,0 0 0 0 0 0 0 0 7 0 0 0 0 ⍝ 7
X←X,2 2 2 0 0 0 0 0 0 0 0 0 0 ⍝ 8
X←X,0 0 0 0 3 3 3 0 0 0 0 0 0 ⍝ 9
X←X,2 0 0 0 0 0 0 5 0 0 0 0 0 ⍝ 10
X←X,0 0 0 0 0 0 0 0 0 11 0 0 0 ⍝ 11
X←X,2 2 0 0 3 0 0 0 0 0 0 0 0 ⍝ 12
X←X,0 0 0 0 0 0 0 0 0 0 13 0 0 ⍝ 13
X←X,2 0 0 0 0 0 0 0 7 0 0 0 0 ⍝ 14
X←X,0 0 0 0 3 0 0 5 0 0 0 0 0 ⍝ 15
X←X,2 2 2 2 0 0 0 0 0 0 0 0 0 ⍝ 16
X←X,0 0 0 0 0 0 0 0 0 0 0 17 0 ⍝ 17
X←X,2 0 0 0 3 3 0 0 0 0 0 0 0 ⍝ 18
X←X,0 0 0 0 0 0 0 0 0 0 0 0 19 ⍝ 19
X←X,2 2 0 0 0 0 0 5 0 0 0 0 0 ⍝ 20

R←×/⌈⌿20 13⍴X