1 / 2
May 2020

import java.util.Scanner;
import java.lang.Math;
class divsum{
public static void main(String[] args) {
Scanner input =new Scanner(System.in);
int noftes=input.nextInt();
for(;noftes>0;noftes–){
int n=input.nextInt();
if(n==1)
System.out.println(0);
else{
int res=1;
//System.out.println((int)Math.sqrt(n));
for(int i=2;i<=(int)Math.sqrt(n)+1;i++){
if(n%i==0)
res+=i+(n/i);
}
System.out.println(res);
}
}
}
}

Can someone pls help me why am i getting WA…

  • created

    May '20
  • last reply

    May '20
  • 1

    reply

  • 449

    views

  • 2

    users

  • 3

    links

It doesn’t even give the correct answers for the sample test cases given in the problem. You need to debug it a little more.

DIVSUM