/******************************************************************************
Online Java Compiler.
Code, Compile, Run and Debug java program online.
Write your code in this editor and press “Run” button to execute it.
******************************************************************************/
/ package codechef; // don’t place package name! */
import java.util.;
import java.lang.;
import java.io.*;
/* Name of the class has to be “Main” only if the class is public. /
public class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
/ package codechef; // don’t place package name! */
/* Name of the class has to be “Main” only if the class is public. */
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
while(t–>0)
{
int n = scan.nextInt();
int a[] = new int[n];
int result = 0;
for(int i=0;i<n;i++)
{
result = Fib(i);
a[i] = result%10;
}
int ans = find_one(a);
System.out.println(ans);
}
}
public static int Fib(int n)
{
if(n==0)
return 0;
else if(n==1)
return 1;
else
return (Fib(n-1)+Fib(n-2));
}
public static int find_one(int a[])
{
int b[] = new int[a.length/2];
int j=0;
for(int i=0;i<a.length;i++)
{
if(i%2==1)
{
b[j]=a[i];
j++;
}
}
if(b.length != 1)
return find_one(b);
else
return b[0];
}
}
ERROR IS:
Main.java:15: error: class Codechef is public, should be declared in a file named Codechef.java
public class Codechef
^
1 error