# Problem 1

### 20 comments on “Problem 1”

• Daksha

#code in python 3
n=int (input ())
if n%2==0:
x=n//2
i=1
c=0
while c <x:
k=0
for j in range (1,i+1):
if i %j ==0:
k+=1
if k ==2:
c+=1
i+=1
print (i-1)
else:
c=0
k=1
×=1
for i in range (1,n//2+1):
x=c+k
c=k
k=x
print (x)

• simran

this question is only valid for 14 term otherwise it produces wrong output
like if we want 13 term the expected output is 13 but by using this code output is 21

write code is:

#include

void fibo(int);

void prime(int);

main()

{

int n,e;

scanf(“%d”,&n);

e=n/2;

if(n%2==0)
prime(e);
else
fibo(e+1);
}

void prime(int n){
int i,j,no,flag=0,count=0;
for(i=2;i<=100;i++){
flag=0;

for(j=2;j<i;j++){
if(i%j==0)
{flag++;
break;} }

if(flag==0)
{count++;}

if(count==n)

{

printf("%d",i);

break;

}

}

}

void fibo(int n)

{

int n0=0,n1=1,n2,i;

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

{

n2=n0+n1;

n0=n1;

n1=n2;

}

printf("%d",n2);

}

• Rayed Ali

#include

void fibo(int);

void prime(int);

int main()

{

int n,e;

scanf(“%d”,&n);

e=n/2;

if(n%2==0)

prime(e);

else

fibo(e+1);

}

void prime(int n)

{

int i,j,no,flag=0,count=0;

for(i=2;i<=100;i++)

{

flag=1;

for(j=2;j<=i/2;j++)

{

if(i%j==0)

flag=0;

}

if(flag==1)

count++;

if (count==n)

{

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

break;

}

}

}

void fibo(int n)

{

int n0=0,n1=1,n2,i;
if (n==1)
printf ("1");
else
{
for(i=1;i<=n-1;i++)
{

n2=n0+n1;

n0=n1;

n1=n2;

}
printf("%d",n2);
}
}

• avi gehlot

n=int(input())
#calculated Fibonacci series
a=0
b=1
for i in range(1,n+1): #number is input 14 (1,14) loop
if(i%2!=0): #14%2==0 means Fibonacci series Not as output
if (i==1):
c=1
else:
c=a+b
a=b #calculated Fibonacci series
b=c
else: # we are go to else part
for k in range(1,n+1): # range for k 1,14
if k>1: # means 1 is not a prime
for j in range(2,k): # range 2,14
if(k%j==0): # this is calculated prime number
k=k+1
else:
x=k
if(i%2!=0):
print(‘{}’.format(c))
else:
print(‘{}’.format(x))

• shruty suman

Correction to the given code:
void fibo(int n)

{

int n0=0,n1=1,n2,i;

if(n==1)
printf(“1”);
else{
for(i=2;i<=n;i++)

{

n2=n0+n1;

n0=n1;

n1=n2;

}

printf("%d",n2);
}
}

• Mohd Saif

n=int(input())
a=0
b=1
for i in range(1,n+1):
if(i%2!=0):
if(i==1):
c=1
else:
c=a+b
a=b
b=c
else:
for k in range(1,n+1):
if k>1:
for j in range(2,k):
if(k%j==0):
k=k+1
else:
x=k

if(i%2!=0):
print(f”The {n} term is:{c}”)
else:
print(f”The {n} term is:{x}”)