You are on page 1of 3

lab- assessment- Internal

Fibonacci series

#include <stdio.h>

int main()
{
//fibonacci series
//0 1 1 2 3 5 8 13

int num;

printf("Enter the no. at possition u wants to find the fibo : ");


scanf("%d",&num);
for(int i =0;i<num+1;i++){
printf("%d",fibo(i));
printf("\n");
}

int fibo(int n){


if(n==0){
return 0;
}
else if(n==1){
return 1;
}
else{
return fibo(n-1)+fibo(n-2);
}
}

Factorial of a number
#include <stdio.h>

int main()
{
//Factorial

int num;
printf("enter the no. whose factorial you wanna find \n");
scanf("%d",&num);

printf(" %d",fact(num));
}
int fact(int num){
if(num==0 || num ==1){
return 1;
}
else{
return num*fact(num-1);
}
}

You might also like