HackerRank Day 19 Interfaces 30 days of code solution YASH PAL, 31 July 202413 October 2025 Hackerrank Day 19 Interfaces problem solution – In this problem set, we need to take an integer input and then we need to subtract that integer and then add all the numbers and print the sum of them on the output screen.ObjectiveToday, we’re learning about Interfaces. TaskThe AdvancedArithmetic interface and the method declaration for the abstract divisorSum(n) method are provided for you in the editor below.Complete the implementation of Calculator class, which implements the AdvancedArithmetic interface. The implementation for the divisorSum(n) method must return the sum of all divisors of n.Examplen = 25The divisors of 25 are 1,5,25. Their sum is 31.n = 20The divisors of 25 are 1,2,4,5,10,20 and their sum is 42. Input FormatA single line with an integer, n.Constraints1 <= n <= 1000Output FormatYou are not responsible for printing anything to stdout. The locked template code in the editor below will call your code and print the necessary output.Problem solution in Python 2 programming.class Calculator(AdvancedArithmetic): def divisorSum(self, n): return divisors(n) def divisors(n): c = 1 s = 0 while c <= n: if n % c == 0: s += c c += 1 return sProblem solution in Python 3 programming.class Calculator(AdvancedArithmetic): def divisorSum(self, n): temp = [] for i in range(1, n+1): if n%i == 0: temp.append(i) return sum(temp)Problem solution in java programming.class Calculator implements AdvancedArithmetic{ public int divisorSum(int n){ // n has no divisors other than itself if(n == 1){ return n; } // Find and sum divisors: int half = n/2; int sum = n; do{ if(n % half == 0){ sum += half; } }while( half-- > 1 ); return sum; } }Problem solution in c++ programming.class Calculator : public AdvancedArithmetic { int divisorSum(int n) { int sum = 0; for (int i = 1; i <= n; i++) { if (n % i == 0) { sum += i; } } return sum; } }; 30 days of code coding problems solutions HackerRank