I am looking for a factorial of a number greater than 10. I use long numbers, but when it comes to adding 1 to the number, (2! = 1 * (1+1)) , the robit function is not true. The question is what did I do wrong? i - the desired number, lengI - the number of digits in the number, n = 1 .
void Plus(char *i, int &lengI, int n) { char c[1000]; int pos = 0; for (int y = lengI - 1; y >= 0; y--) { c[pos] = i[y]; pos++; } pos = 0; c[0] += n; bool change = false; while (c[pos] >= 10) { bool change = true; c[pos + 1]++; c[pos++] -= 10; } if (change) lengI++; pos = 0; for (int z = lengI - 1; z >= 0; z--) { i[pos] = c[z]; pos++; } }