We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Tutorials
  3. 30 Days of Code
  4. Day 19: Interfaces
  5. Discussions

Day 19: Interfaces

Problem
Submissions
Leaderboard
Discussions
Editorial
Tutorial

Sort 757 Discussions, By:

recency

Please Login in order to post a comment

  • vgh_peter
    1 month ago+ 0 comments
    class Calculator(AdvancedArithmetic):
        def divisorSum(self, n):
            divisors=[]
            for num in range(1,n+1):
                if n%num==0:
                    divisors.append(num)
            return sum(divisors)
    
    0|
    Permalink
  • deepakchaudhari2
    1 month ago+ 0 comments

    interfaces solution using Typescript or JavaScript and All solution of HackerRank https://github.com/deepak14ri/Hackerrank-30-Day-Challenge

    function main() {
            // Enter your code here
            var n = Number(inputLines[0]);
            var sum = 0;
            for(let i=1;i<=n;i++){
                    if(n%i==0){
                            sum+=i;   
                    } 
            }
            console.log('I implemented: AdvancedArithmetic'+'\n'+sum);
    

    }

    0|
    Permalink
  • ehabmagdy
    1 month ago+ 0 comments

    My solution

    int divisors_sum = n;
    for(int i = 1 ; i <= n/2 ; i++){
        if(n % i == 0)
            divisors_sum += i;
    }
    return divisors_sum;
    
    0|
    Permalink
  • johanna_blument1
    1 month ago+ 0 comments

    I am a little bit confused. I "solved" the challenge, but it doesn't seem like they even needed/wanted to specifically implement an interface. Even the linked tutorial uses interface and implements the way I was taught, but the stub code forces different syntax becasue you can't redesign AdvancedArithmetic to be an interface. Which Cacluate would then implement. Can someone explain? BTW I am solving the challenges in python.

    0|
    Permalink
  • clrk_montano
    2 months ago+ 1 comment

    Python 3

    def divisorSum(self, n):
            divisor = [x for x in range(1, n+1) if n % x == 0]
            return sum(divisor)
    
    0|
    Permalink
Load more conversations

Need Help?


View tutorial
View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy