The code that I wrote in Eclipse is running perfectly but the same code while I am trying to run here it is showing error.
The error is Exception in thread “main” java.util.NoSuchElementException.
My code is
Scanner scn=new Scanner(System.in);
int n=scn.nextInt();
int i,num=0,m=n-1;
for(i=0;i<n;i++){
int a=2;
Scanner sc=new Scanner(System.in);
int N=sc.nextInt();
num=num+N*(int)Math.pow(a,m);
m--;
//System.out.println(+num);
}
System.out.println(+num);
P.S. I have imported the Math library for using the power function.