Skip to main content
2 of 2
Commonmark migration

05AB1E, 18 bytes

<Ø[₂‰˜0KZ27‹#}<Asè

Isn't there a convenient builtin to do this shorter?.. I have the feeling I should be able to use one of the base-conversion builtins here, but it isn't really working out.. Can without a doubt be golfed substantially, though..

Try it online or verify some more test cases.

Explanation:

<              # Decrease the (implicit) input-integer by 1 to make it 0-based
 Ø             # Get the 0-based n'th prime
  [            # Start an infinite loop:
   ₂‰          #  Take the divmod 26
     ˜         #  Flatten the resulting list
      0K       #  And remove any 0s
        Z      #  Get the maximum of the list (without popping)
         27‹   #  If it's smaller than 27:
            #  #   Stop the infinite loop
  }<           # After the loop: decrease all values by 1 to make it 0-based
    A          # Push the lowercase alphabet
     sè        # And index the list of integers into it
               # (after which the resulting character-list is output implicitly as result)
Kevin Cruijssen
  • 131.4k
  • 13
  • 144
  • 384