36 lines
399 B
C
36 lines
399 B
C
#include <stdio.h>
|
|
|
|
// Declaración de función recursiva
|
|
int x(int n);
|
|
|
|
// Función recursiva x
|
|
int x(int n)
|
|
{
|
|
if (n <= 1)
|
|
{
|
|
return n;
|
|
}
|
|
else
|
|
{
|
|
return x(n - 1) + x(n - 2);
|
|
}
|
|
}
|
|
|
|
// Función principal (main)
|
|
int main()
|
|
{
|
|
int n;
|
|
|
|
n = 1;
|
|
|
|
while (n <= 5)
|
|
{
|
|
printf("%d ", x(n));
|
|
n = n + 1;
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
return 0;
|
|
}
|