Похожие чаты

Helo gais, i am not a c dev but kind want

to check wasm , wrote one fibonacci thing, but it will overflow after a while when the input element grows, how to tackle it ? if possible without breaking my head and without gmp or other libraries?
unsigned long long fibonaccisum(int n) {
unsigned long long a = 0, b = 1, temp, sum = 1;

if (n <= 1) {
return n;
}

for (int i = 2; i <= n; ++i) {
temp = a + b;
a = b;
b = temp;
}

return b;
}

3 ответов

23 просмотра

temp = a + b -- cause to overflow

Jass- Автор вопроса
²
temp = a + b -- cause to overflow

ya but the fibonacci sum itself will cause it , i see no way to avoid it unless i have my custom return type that is formed by either some kinda array system or gmp

Jass
ya but the fibonacci sum itself will cause it , i ...

well you will have to work with strings instead

Похожие вопросы

Обсуждают сегодня

Карта сайта