using static System.Console ;
public class Program {
public static void Main( ) {
for ( int i = 1 ; i >= 0 ; i *= 2 ) { WriteLine( $"i: {i}" ) ; }
checked {
for ( int j = 1 ; j >= 0 ; j *= 2 ) { WriteLine( $"j: {j}" ) ; }
}
}
}
//https://pt.stackoverflow.com/q/326539/101
dXNpbmcgc3RhdGljIFN5c3RlbS5Db25zb2xlOwoKcHVibGljIGNsYXNzIFByb2dyYW0gewoJcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKSB7CgkJZm9yIChpbnQgaSA9IDE7IGkgPj0gMDsgaSAqPSAyKSB7IFdyaXRlTGluZSgkImk6IHtpfSIpOyB9CgkJY2hlY2tlZCB7CgkJCWZvciAoaW50IGogPSAxOyBqID49IDA7IGogKj0gMikgeyBXcml0ZUxpbmUoJCJqOiB7an0iKTsgfQoJCX0KCX0KfQoKLy9odHRwczovL3B0LnN0YWNrb3ZlcmZsb3cuY29tL3EvMzI2NTM5LzEwMQ==
stdout
i: 1
i: 2
i: 4
i: 8
i: 16
i: 32
i: 64
i: 128
i: 256
i: 512
i: 1024
i: 2048
i: 4096
i: 8192
i: 16384
i: 32768
i: 65536
i: 131072
i: 262144
i: 524288
i: 1048576
i: 2097152
i: 4194304
i: 8388608
i: 16777216
i: 33554432
i: 67108864
i: 134217728
i: 268435456
i: 536870912
i: 1073741824
j: 1
j: 2
j: 4
j: 8
j: 16
j: 32
j: 64
j: 128
j: 256
j: 512
j: 1024
j: 2048
j: 4096
j: 8192
j: 16384
j: 32768
j: 65536
j: 131072
j: 262144
j: 524288
j: 1048576
j: 2097152
j: 4194304
j: 8388608
j: 16777216
j: 33554432
j: 67108864
j: 134217728
j: 268435456
j: 536870912
j: 1073741824
stderr
Unhandled Exception:
System.OverflowException: Arithmetic operation resulted in an overflow.
at Program.Main () [0x00043] in <7036407466f24234a4d2e95205c4fde4>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.OverflowException: Arithmetic operation resulted in an overflow.
at Program.Main () [0x00043] in <7036407466f24234a4d2e95205c4fde4>:0