hacker 41th problem solution (java interface)
41. JAVA INTERAFCE
class MyCalculator implements AdvancedArithmetic{
int sum=0;
public int divisor_sum(int n)//create a method of inner interface implemented
{
for(int i=1;i<n+1;i++){
if(n%i==0){
sum=sum+i;
}
}
return sum;
}
}
Comments