Skip to main content
added 371 characters in body
Source Link
Jonathan Allan
  • 110.2k
  • 7
  • 65
  • 282

Jelly, 3 bytes

>ŻY

A full program that accepts a non(non-negative*) integer, \$x\$, and prints \$x\$ ones followed by a zero.

* negative integers will do the same as zero.

Try it online!

How?

>ŻY - Main Link: non-negative integer, X   e.g. 0      3
 Ż  - zero range                                [0]    [0,1,2,3]
>   - {X} greater than {that}?                  [0]    [1,1,1,0]
  Y - join with newline characters
    - implicit, smashing print

Jelly, 3 bytes

>ŻY

A full program that accepts a non-negative integer, \$x\$, and prints \$x\$ ones followed by a zero.

Try it online!

Jelly, 3 bytes

>ŻY

A full program that accepts a (non-negative*) integer, \$x\$, and prints \$x\$ ones followed by a zero.

* negative integers will do the same as zero.

Try it online!

How?

>ŻY - Main Link: non-negative integer, X   e.g. 0      3
 Ż  - zero range                                [0]    [0,1,2,3]
>   - {X} greater than {that}?                  [0]    [1,1,1,0]
  Y - join with newline characters
    - implicit, smashing print
Source Link
Jonathan Allan
  • 110.2k
  • 7
  • 65
  • 282

Jelly, 3 bytes

>ŻY

A full program that accepts a non-negative integer, \$x\$, and prints \$x\$ ones followed by a zero.

Try it online!