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;
  }
}

Compiler Message
Success
Input (stdin)Download
6
Expected OutputDownload
I implemented: AdvancedArithmetic
12

Comments

Popular posts from this blog

Amazon Web Services

Google Code-In mentorship experience :)

Hacker Rank all java and python problem solutions