mirror of
https://gitlab.gwdg.de/j.hahn02/university.git
synced 2026-01-01 14:54:25 -05:00
cleanup
This commit is contained in:
9
S1/GdCP/a02.c
Normal file
9
S1/GdCP/a02.c
Normal file
@@ -0,0 +1,9 @@
|
||||
int sequence(int x, int n){
|
||||
if (n < 0) return 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (x % 2 == 0) x = x/2;
|
||||
else x = 3 * x + 1;
|
||||
if (x < 0) return -1;
|
||||
}
|
||||
return x;
|
||||
};
|
||||
Reference in New Issue
Block a user