Skip to main content
3 of 5
deleted 2 characters in body
Nahuel Fouilleul
  • 8.6k
  • 1
  • 10
  • 18

#Perl 5 (-n), 41 bytes

map{/01.*1/||say oct"0b$_"}glob"{0,1}"x$_

TIO

  • "{0,1}"x$_ : the string "{0,1}" repeated n times
  • glob : glob expansion (cartesian product)
  • map{...} : for each element
  • /01.*1/|| : to skip when 01 followed by something then 1
  • say oct"0b$_" : to convert to decimal and say
Nahuel Fouilleul
  • 8.6k
  • 1
  • 10
  • 18