+1 vote

#Program to compute first 15 numbers of the fibonacci series

#!/usr/bin/env/python3

def fibonacci(n):

if n < 0:

print("wrong input")

elif n == 0:

return 0

elif n == 1:

return 1

else:

return fibonacci(n - 1) + fibonacci(n - 2)

for i in range(0, 15):

print(fibonacci(i))

#!/usr/bin/env/python3

def fibonacci(n):

if n < 0:

print("wrong input")

elif n == 0:

return 0

elif n == 1:

return 1

else:

return fibonacci(n - 1) + fibonacci(n - 2)

for i in range(0, 15):

print(fibonacci(i))

0 votes

#include<stdio.h>

int main(void)

{

int x[100],n=15,i,j,a;

for(i=0;i<n;i++)

{

for(j=0;j<3;j++)

{

if(j<=2)

{

x[j]=j+1;

a=a+x[j];

}

x[i+2]=x[i]+x[i+1];

a=a+x[i];

}

}

printf("\nseries are:");

for(i=0;i<n;i++)

{

printf("%d\t",x[i]);

}

printf("\n sum of series no.:%d",a);

return 0;

int main(void)

{

int x[100],n=15,i,j,a;

for(i=0;i<n;i++)

{

for(j=0;j<3;j++)

{

if(j<=2)

{

x[j]=j+1;

a=a+x[j];

}

x[i+2]=x[i]+x[i+1];

a=a+x[i];

}

}

printf("\nseries are:");

for(i=0;i<n;i++)

{

printf("%d\t",x[i]);

}

printf("\n sum of series no.:%d",a);

return 0;

0 votes

**Assuming Language required C it will not compute 15 no you can define how many no you want to compute for**

#include<stdio.h>

void main()

{

int n,new,i;

int a[2]={0,1};

printf("Enter the no up to where you want to find the series\n");

scanf("%d",&n);

printf(" Fibonacci series\n0\n1\n");

for(i=3;i<=n;i++)

{

new=a[0]+a[1];

printf("%d\n",new);

a[0]=a[1];

a[1]=new;

}

}

...