Aggiorna test.c
This commit is contained in:
parent
257f9c9b40
commit
5bcc030c6d
1 changed files with 15 additions and 18 deletions
27
test.c
27
test.c
|
|
@ -1,21 +1,18 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
int main() {
|
int fibonacci( int n ) {
|
||||||
int a, b, c, i, n;
|
n = 1000000;
|
||||||
|
if ( n <= 1 ) return n;
|
||||||
n = 10000;
|
return fibonacci( n - 1 ) + fibonacci ( n - 2);
|
||||||
|
|
||||||
a = b = 1;
|
|
||||||
|
|
||||||
printf("%d %d ",a,b);
|
|
||||||
|
|
||||||
for(i = 1; i <= n-2; i++) {
|
|
||||||
c = a + b;
|
|
||||||
printf("%d ", c);
|
|
||||||
|
|
||||||
a = b;
|
|
||||||
b = c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
if (argc != 2) {
|
||||||
|
printf("Usage: %s <number>\n", argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
int n = atoi(argv[1]);
|
||||||
|
printf("%d\n", fibonacci(n));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue