0

Why is this code not working in Sololearn? g (1,3)

int g (int x, int n) { for (int i = 0; i < n; i++) { if (i % 2 == 0) { x *= i + 1; continue; } x--; if (x == 0) { break; } } return x; }

3rd Apr 2020, 8:01 PM
Mohamad Alkaleeh
5 odpowiedzi
0
try this code : int g (int x, int n) { int y =x; for(int i = 0;i < n; i++) { if (i % 2 == 0){ y *= i + 1; continue; } y - - ; if (y ==0){ break ; } } return y; }
3rd Apr 2020, 8:19 PM
Mostafa
0
did not work
3rd Apr 2020, 8:34 PM
Mohamad Alkaleeh
0
hm can u give me error message?
3rd Apr 2020, 8:36 PM
Mostafa
0
int g (int x, int n) { for (int i = 0; i < n; i++) { if (i % 2 == 0) { x *= i + 1; continue; } x--; if (x == 0) { break; } } return x; } I'm sure this code correct, but why isn't working on the sololearn program? Should I add something Can you turn it on ، share it here and thank you
3rd Apr 2020, 8:43 PM
Mohamad Alkaleeh
0
g(1,3)
3rd Apr 2020, 8:48 PM
Mohamad Alkaleeh