This is Discussion thread about Facto Sum
Discussion About Facto Sum
kindly check this code,as it is giving wrong answer for 3 of 5 test cases
import java.util.;
public class Main {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int N=sc.nextInt();
int[] arr=new int[N];
for(int i=0;i<N;i++){
arr[i]=sc.nextInt();
}
int result=(int)(sumof(arr,N)%107);
System.out.println(result);
}
public static int factsum(int a){
int f=1;
for(int i=1;i<=a;i++){
f=i;
}
return f;
}
public static int sumof(int[] b,int n){
int s=0;
for(int i=0;i<n;i++){
s+=factsum(b[i]);
}
return s;
}
}
Use long datatype to store output instead of int.