top | item 45975930

(no title)

kiratp | 3 months ago

A loop either never halts or has a conditional. I guess a compiler could elide a “while True:” to a branch-less jump instruction.

One hack would be to use recursion and let stack exhaustion stop you.

discuss

order

nodja|3 months ago

Count down i from 100 to 0 and do 1/i at the end of the loop :)

buzer|3 months ago

Other would be to use goto (though Python doesn't have it) & introduce something that will panic/throw exception, like creating variable with value 1/(max-i).

pinusc|3 months ago

Recursion would work for that, you don't need goto.

The division by zero trick is pretty good too!

TZubiri|3 months ago

You could allocate 100 bytes and get a segfault on 101