Hello This program has to be done in EclipseProgram used to
Hello. This program has to be done in Eclipse(Program used to write java code)
Write a program that prints the first 30 numbers in the Fibonacci sequence while omitting the third number(it is replaced with an X)
Ex: 0,1,X,2,3,X,18.....
I have most of the code but, cannot figure out the part on how to delete every third number in the sequence
1 import java.util.*; 2 public class Fibonaccii 3e 4 5 6 7 public static void main (String[] args) i Scanner s= new Scanner (System.in); System. out.println (\"Enter you desired value of n: \") int n = s.nextInt(); for (int i = 0; |Solution
import java.util.*;
public class Fibonacci{
public static int fibonacci(int n){
if (n==0){
return 0;
}
else if(n==1){
return 1;
}
else{
return fibonacci(n-1)+fibonacci(n-2);
}
}
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
for (int i=1; i<=n; i++){
if(i%3!=0){
System.out.print(fibonacci(i-1)+\" \");
}
else{
System.out.print(\"X \");
}
}
}
}
