Skip to main content
Added weird undefined-behavior version
Source Link
DLosc
  • 39.2k
  • 5
  • 83
  • 141

Forte (Forter), 4525 bytes

1PUT5PRINT"ol";:LET5=1
1PUT76

Try it online!

Explanation

An undefined behavior exploit courtesy of Jo King:

1 PUT 76

Print an L character.

5 PRINT "ol"; : LET 5 = 1

Print ol without a final newline, and set 5 to 1.

Apparently, this overwrites the former line 1 with the former line 5, and thus (lacking an END statement) the PRINT "ol"; line is executed repeatedly forever. But I don't really understand how this works--especially since it only works if you write line 5 before line 1, not vice versa...


Here's a 44-byte version that doesn't use any undefined behavior:

1PUT76
5PRINT"ol";:LET6=6+0
6LET0=2:LET5=5+2

Try it online!Try it online!

Explanation

1 PUT 76

Print an L character.

5 PRINT "ol"; : LET 6 = 6 + 0

Print ol without a final newline, and set 6 to 6.

6 LET 0 = 2 : LET 5 = 5 + 2

Set 0 to 2, and set 5 to 7.

5 7 PRINT "ol"; : LET 6 = 6 + 0 2

Print ol again, and set 6 to 8.

6 8 LET 0 2 = 2 : LET 5 7 = 5 7 + 2

Set 2 to 2, and set 7 to 9.

5 7 9 PRINT "ol"; : LET 6 8 = 6 8 + 0 2

Print ol again, and set 8 to 10.

And so on forever.

Forte, 45 bytes

1PUT 76
5PRINT"ol";:LET6=6+0
6LET0=2:LET5=5+2

Try it online!

Explanation

1 PUT 76

Print an L character.

5 PRINT "ol"; : LET 6 = 6 + 0

Print ol without a final newline, and set 6 to 6.

6 LET 0 = 2 : LET 5 = 5 + 2

Set 0 to 2, and set 5 to 7.

5 7 PRINT "ol"; : LET 6 = 6 + 0 2

Print ol again, and set 6 to 8.

6 8 LET 0 2 = 2 : LET 5 7 = 5 7 + 2

Set 2 to 2, and set 7 to 9.

5 7 9 PRINT "ol"; : LET 6 8 = 6 8 + 0 2

Print ol again, and set 8 to 10.

And so on forever.

Forte (Forter), 25 bytes

5PRINT"ol";:LET5=1
1PUT76

Try it online!

Explanation

An undefined behavior exploit courtesy of Jo King:

1 PUT 76

Print an L character.

5 PRINT "ol"; : LET 5 = 1

Print ol without a final newline, and set 5 to 1.

Apparently, this overwrites the former line 1 with the former line 5, and thus (lacking an END statement) the PRINT "ol"; line is executed repeatedly forever. But I don't really understand how this works--especially since it only works if you write line 5 before line 1, not vice versa...


Here's a 44-byte version that doesn't use any undefined behavior:

1PUT76
5PRINT"ol";:LET6=6+0
6LET0=2:LET5=5+2

Try it online!

Explanation

1 PUT 76

Print an L character.

5 PRINT "ol"; : LET 6 = 6 + 0

Print ol without a final newline, and set 6 to 6.

6 LET 0 = 2 : LET 5 = 5 + 2

Set 0 to 2, and set 5 to 7.

5 7 PRINT "ol"; : LET 6 = 6 + 0 2

Print ol again, and set 6 to 8.

6 8 LET 0 2 = 2 : LET 5 7 = 5 7 + 2

Set 2 to 2, and set 7 to 9.

5 7 9 PRINT "ol"; : LET 6 8 = 6 8 + 0 2

Print ol again, and set 8 to 10.

And so on forever.

Source Link
DLosc
  • 39.2k
  • 5
  • 83
  • 141

Forte, 45 bytes

1PUT 76
5PRINT"ol";:LET6=6+0
6LET0=2:LET5=5+2

Try it online!

Explanation

1 PUT 76

Print an L character.

5 PRINT "ol"; : LET 6 = 6 + 0

Print ol without a final newline, and set 6 to 6.

6 LET 0 = 2 : LET 5 = 5 + 2

Set 0 to 2, and set 5 to 7.

5 7 PRINT "ol"; : LET 6 = 6 + 0 2

Print ol again, and set 6 to 8.

6 8 LET 0 2 = 2 : LET 5 7 = 5 7 + 2

Set 2 to 2, and set 7 to 9.

5 7 9 PRINT "ol"; : LET 6 8 = 6 8 + 0 2

Print ol again, and set 8 to 10.

And so on forever.