Skip to main content
added 46 characters in body
Source Link
nimi
  • 35.9k
  • 4
  • 34
  • 99

Haskell, 48 4646 43 bytes

f 2=1
f n=last[d|d<-[1.n=until((<1).n-1],mod n d<1]+f)pred(n-1)+f(n-1)

Try it online!Try it online!

Edit: @rogaos saved two bytes. Thanks!

Edit II: ... and @xnor another 3 bytes.

Haskell, 48 46 bytes

f 2=1
f n=last[d|d<-[1..n-1],mod n d<1]+f(n-1)

Try it online!

Edit: @rogaos saved two bytes. Thanks!

Haskell, 48 46 43 bytes

f 2=1
f n=until((<1).mod n)pred(n-1)+f(n-1)

Try it online!

Edit: @rogaos saved two bytes. Thanks!

Edit II: ... and @xnor another 3 bytes.

added 53 characters in body
Source Link
nimi
  • 35.9k
  • 4
  • 34
  • 99

Haskell, 4848 46 bytes

f n=sum[last[d|d<2=1
f n=last[d|d<-[1..xn-1],mod xn d<1]|x<d<1]+f(n-[2..n]]1)

Try it online!Try it online!

Edit: @rogaos saved two bytes. Thanks!

Haskell, 48 bytes

f n=sum[last[d|d<-[1..x-1],mod x d<1]|x<-[2..n]]

Try it online!

Haskell, 48 46 bytes

f 2=1
f n=last[d|d<-[1..n-1],mod n d<1]+f(n-1)

Try it online!

Edit: @rogaos saved two bytes. Thanks!

Source Link
nimi
  • 35.9k
  • 4
  • 34
  • 99

Haskell, 48 bytes

f n=sum[last[d|d<-[1..x-1],mod x d<1]|x<-[2..n]]

Try it online!