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;
}
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
well you will have to work with strings instead
Обсуждают сегодня