From 5bcc030c6da8ed487dcce366d2bd77d8e121445e Mon Sep 17 00:00:00 2001 From: PanSi21 Date: Sat, 4 Jan 2025 23:55:08 +0100 Subject: [PATCH] Aggiorna test.c --- test.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/test.c b/test.c index 724681b..e11ec2f 100644 --- a/test.c +++ b/test.c @@ -1,21 +1,18 @@ #include +#include -int main() { - int a, b, c, i, n; - - n = 10000; - - 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; - } - - return 0; +int fibonacci( int n ) { + n = 1000000; + if ( n <= 1 ) return n; + return fibonacci( n - 1 ) + fibonacci ( n - 2); +} + +int main(int argc, char *argv[]) { + if (argc != 2) { + printf("Usage: %s \n", argv[0]); + return 1; + } + int n = atoi(argv[1]); + printf("%d\n", fibonacci(n)); + return 0; }