You are given an input n as an integer input , Write a program to print the alternate fibonacci numbers starting from the first fibonacci till the nth fibonacci numbers accordingly , if nth fibonacci number is part of the series or not.
Input Format
For each test case, you will get n as an integer input.
Constraints
1<=n<=50
Output Format
Print the output in a single line.
Sample Input 0
10
Sample Output 0
0 1 3 8 21
Explanation 0
Alternate fibonacci till nth fibonacci are: 0 1 3 8 21
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int a=0, b=1, c;
for(int i=1; i<=n; i++){
c=-1;
if(i%2!=0)
System.out.print(a+" ");
c=a+b;
a=b;
b=c;
}
}
}