# c语言中递归函数真的好吗？

`#include<stdio.h>#include<stdlib.h>long factorial(int n){ if (n <= 0) return 1; else return n*factorial(n - 1);}int main(){ int n = 5; printf("%ld/n", factorial(n)); system("pause"); return 0;}`

`#include<stdio.h>#include<stdlib.h>long factorial(int n){ int result = 1; while (n > 1) { result *= n; n--; } return result;}int main(){ int n = 5; printf("%ld/n", factorial(n)); system("pause"); return 0;}`

`#include<stdio.h>#include<stdlib.h>long fibonacci(int n){ if (n <= 2) return 1; return fibonacci(n - 1) + fibonacci(n - 2);}int main(){ int n = 5; printf("%ld/n", fibonacci(n)); system("pause"); return 0;}`

`#include<stdio.h>#include<stdlib.h>//计算Fibonaccilong Fibonacci(int n){ long result = 0; long first = 0; long second = 0; result = first = 1; while (n > 2) //效率远远高于递归 { n -= 1; second = first; first = result; result = first + second; } return result;}int main(){ int n = 5; printf("%ld/n",Fibonacci(n)); system("pause"); return 0;}这个迭`

second        first        result
1               1             2
1               2             3
2               3             5
3               5             8
......