# fibonacci(10,000)

• 05-19-2005
blindman858
fibonacci(10,000)
Greetings,

Ok I know how to code fibonacci using both iterative and recursive functions. However, I have no idea how to go about calculating the 10,000 fibonacci. That is a very very very big number. I think I may have to use an array of sometype to solve this because i dont think visual studios has a data type that can handle such a gigantic number. But I dont know how to begin. If any you could provide insight and suggestions I would greatly appreciate it. Thanks.
• 05-19-2005
Salem
Use a bignum library - http://www.swox.com/gmp/
• 05-19-2005
MathFan
Take a look at this page http://www.codearchive.com/list.php?go=0716. - almost at the bottom of it. Here you can download source code of an example program that can handle really large fibonacci numbers.

Here is some more source code you can look at http://sourceforge.net/project/showf...kage_id=125989

Hope this helps :)
• 05-19-2005
Thantos
Quote:

Originally Posted by blindman858
Greetings,

Ok I know how to code fibonacci using both iterative and recursive functions. However, I have no idea how to go about calculating the 10,000 fibonacci. That is a very very very big number. I think I may have to use an array of sometype to solve this because i dont think visual studios has a data type that can handle such a gigantic number. But I dont know how to begin. If any you could provide insight and suggestions I would greatly appreciate it. Thanks.

To calculate a fibonacci of this size you don't use an iterative or recursive approach. Instead you find the formula that lets you solve directly.

http://en.wikipedia.org/wiki/Fibonacci_number

And of course you use bignum libraries :)
• 05-20-2005
xErath
I've already done this long time ago
Code:

```#include<stdio.h> #define SIZE_NUM 1000000000 #define VECTOR_DIM 234//enough to hold fib(10000) /*MACRO output number*/ #define display_arr(vec)\         /*display the array code*/                                 int main() {         int i=-1, opt;         int indfin=1, ref=1;         unsigned int n0[VECTOR_DIM] = {0}, n1[VECTOR_DIM] = {1};         unsigned int temp;         scanf("%d", &opt);         if(!opt)         printf("The Fibonacci number for 0 is 0");         else{                 while(i++<opt){/*sum cicle*/                         /*...............*/                 }                                 /*        display*/                 printf("The Fibonacci number for %d is ", opt);                 if(ref)  display_arr(n0)                 else  display_arr(n1)         }         putchar('\n');                 getchar();         return 0; }```
Beg for the full source if you want;)