-1

Given a number N, find the sum of all products x*y such that N/x = y (Integer Division). Since, the sum can be very large, please output this modulo 1000000007. Input

The first line of input file contains an integer T, the number of test cases to follow. Each of the next T lines contain an integer N. Output

Output T lines containing answer to corresponding test case. `

private static Scanner sc;
public static void main(String [] args ){

    sc = new Scanner(System.in);long k;int s;
    int t = sc.nextInt(); 
    while(t>0){
        k=0;
     long n = sc.nextInt();
     for(int i=1;i<=n;i++){

             k=k+(n/i)*i;



     }



     s=(int) (k%1000000007);
     System.out.println(s);
}t--;
}

1 Answers1

0

I didn't get any such exception while executing the above program. But you should put t-- inside the while loop. Otherwise it will run infinitely.

N-C
  • 13
  • 1
  • 5