Skip to main content
Commonmark migration
Source Link

#Befunge 98, 22

Befunge 98, 22

&:00pv>0gk,@
0::-1<^j`

Kind of sad that this is so long.

&:00p        ; gets numerical input, stores a copy at cell (0,0)               ;
     v       ; IP goes down                                                    ;

     <       ; IP goes left, so I execute 1-::0`j^                             ;
 ::-1        ; (1-::) subtract one from our number and duplicate it twice      ;
0       `    ; (0`) compare the number with 0, push 1 if greater else 0        ;
     <^j     ; if the result was 0, go up, otherwise continue going left       ;

      >0gk,  ; get the value at cell (0,0), print that many numbers from stack ;
           @ ; terminate program                                               ;

#Befunge 98, 22

&:00pv>0gk,@
0::-1<^j`

Kind of sad that this is so long.

&:00p        ; gets numerical input, stores a copy at cell (0,0)               ;
     v       ; IP goes down                                                    ;

     <       ; IP goes left, so I execute 1-::0`j^                             ;
 ::-1        ; (1-::) subtract one from our number and duplicate it twice      ;
0       `    ; (0`) compare the number with 0, push 1 if greater else 0        ;
     <^j     ; if the result was 0, go up, otherwise continue going left       ;

      >0gk,  ; get the value at cell (0,0), print that many numbers from stack ;
           @ ; terminate program                                               ;

Befunge 98, 22

&:00pv>0gk,@
0::-1<^j`

Kind of sad that this is so long.

&:00p        ; gets numerical input, stores a copy at cell (0,0)               ;
     v       ; IP goes down                                                    ;

     <       ; IP goes left, so I execute 1-::0`j^                             ;
 ::-1        ; (1-::) subtract one from our number and duplicate it twice      ;
0       `    ; (0`) compare the number with 0, push 1 if greater else 0        ;
     <^j     ; if the result was 0, go up, otherwise continue going left       ;

      >0gk,  ; get the value at cell (0,0), print that many numbers from stack ;
           @ ; terminate program                                               ;
Source Link
Justin
  • 21.3k
  • 9
  • 67
  • 114

#Befunge 98, 22

&:00pv>0gk,@
0::-1<^j`

Kind of sad that this is so long.

&:00p        ; gets numerical input, stores a copy at cell (0,0)               ;
     v       ; IP goes down                                                    ;

     <       ; IP goes left, so I execute 1-::0`j^                             ;
 ::-1        ; (1-::) subtract one from our number and duplicate it twice      ;
0       `    ; (0`) compare the number with 0, push 1 if greater else 0        ;
     <^j     ; if the result was 0, go up, otherwise continue going left       ;

      >0gk,  ; get the value at cell (0,0), print that many numbers from stack ;
           @ ; terminate program                                               ;