Created
January 25, 2019 01:43
-
-
Save kaityo256/11c5bb56da06e0d7e8036350ba74781f to your computer and use it in GitHub Desktop.
demons fly out of your nose
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Modified from https://qiita.com/tkmtSo/items/de3148dd1dcb70f38d6a | |
| #include <cstdio> | |
| int collatz(int n) { | |
| while (true) { | |
| if (n == 1) | |
| return 1; | |
| if (n % 2 == 0) { | |
| n /= 2; | |
| } else { | |
| n = 3 * n + 1; | |
| } | |
| } | |
| } | |
| int test(int n) { | |
| return collatz(n); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The function
testreturns 1 without any calculation!