C
x
34
1
2
3
4
int seq(int x)
5
{
6
printf("out if x = %d \n",x);
7
if(x<=4)
8
{
9
printf("x in if x = %d \n",x);
10
return x;
11
}
12
else
13
{
14
printf("x out else = %d \n",x);
15
return seq(x-4)+2*seq(x-3)+3*seq(x-2)+4*seq(x-1);
16
}
17
18
}
19
20
int main()
21
{
22
int x,result;
23
24
printf("Inform N: ");
25
scanf("%d",&x);
26
27
result = seq(x);
28
29
30
printf("\n An = %d \n",result);
31
32
return 0;
33
}
34
$ gcc prog.c -Wall -Wextra -std=gnu11
Stdin
5
Start
Inform N: out if x = 5 x out else = 5 out if x = 1 x in if x = 1 out if x = 2 x in if x = 2 out if x = 3 x in if x = 3 out if x = 4 x in if x = 4 An = 30
0
Finish