what is the problem?
Sample Input 3 2 2 4 8 1 3 2 3 Sample Output 1 3 Explanation For query 1: GCD(F(2) , F(4), F(8))= GCD(1,3,21)=1 For query 2: GCD(F(4), F(8))= GCD(3,21)=3 import java.util.*; class TestClass { public static void main(String args[] ) throws Exception { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int q=sc.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++) a[i]=sc.nextInt(); for(int i=0;i<q;i++) { int l=sc.nextInt(); int r=sc.nextInt(); int gc=fibo(a[l-1]); // System.out.print(gc); for(int j=l;j<r;j++) { int y=fibo(a[j]); // System.out.print(y+" "); gc=gcd(gc,y); System.out.println(gc); } } static int gcd(int x,int e) { int p=1; while(x!=0){ int z=x; p=e/x; x=e%x; e=z; } return e; } static int fibo(int f) { int d=0,c=0; int a=1,b=0; while(d<f) { c=a+b; a=b; b=c; d++; } return c; }