Skip to main content
2 of 4
added 289 characters in body
Uriel
  • 13.3k
  • 4
  • 18
  • 45

APL (Dyalog), 50 bytes

Look 'ma, no built-in totient!

0{⍵=1:⍺⋄(⍺+1)∇×/⍵,1-÷o/⍨0=⍵|⍨o←(⊢~∘.×⍨)1+⍳⍵}¨1+⍳99 

Try it online!

How?

(⊢~∘.×⍨)1+⍳⍵ - primes (better don't ask)

o/⍨ - filter by

0=⍵|⍨o - divisibility by n

1-÷o - array wise 1- recipeocal

×/⍵, - prepend n, and multiply 'em all

This is the totient. All the rest is wrapper for the counting and applying on 2..100.

Uriel
  • 13.3k
  • 4
  • 18
  • 45