Skip to main content
1 of 4
Tbw
  • 3k
  • 4
  • 29

APL(Dyalog Unicode), 10 bytes SBCS

{⍵∊+\+\⍳⍵} 

Try it on APLgolf!

Same as the Vyxal and Uiua answers.

Tbw
  • 3k
  • 4
  • 29