/***********************************************************
collatz.c -- Collatz (コラッツ) の予想
***********************************************************/
#N88BASIC

Const LIMIT = ((4294967295 - 1) / 3)

Sub main()
Dim n As DWord

Print "n = ";
Input n
while (n > 1)
If (n And 1) Then /* 奇数 */
if (n > LIMIT) Then
print "Overflow"
Exit Sub
Else
n = 3 * n + 1
End If
Else
n = n / 2

End If
Print n
Wend
End Sub


main()