**Problem:-**Write a Hackerrank Solution For Day 19: Interfaces or Hacker Rank Solution Program In C++ For " Day 19: Interfaces " or Hackerrank 30 days of code Java Solution:Day 19: Interfaces solution or Hackerrank solution for 30 Days of Code Challenges or Hackerrank 30 days of code Java Solution, Day 19: Interfaces solution, or C/C++ Logic & Problem Solving: Day 19: Interfaces or Hacker Rank Solution For Day 19: Interfaces.

**Check This:-**Hacker rank solution for Strings, Classes, STL, Inheritance in C++.

**Explanation:-**This is a very simple problem(Interfaces) we have to just calculate divisor sum and print the sum of the divisor. we can do this by run the loop(started with 1 and end with N) and put the condition if number N is divided by I(where I = 1 to N) than the sum of the divisor is added each time when if N%I==0. Let's take an example and try to understand the problem step by step.

**Example:-**Let's assume Number N is 24 and we have to calculate the Divisor sum so we divide the number by I=1 to I=24 with the help of "For Loop" Take a look at step by step.

**Step 1:**If(N % I ==0) then Sum or total is Sum = Sum + I Or Total = Total + I.

**Step 2:**Print the total outside the "For Loop". Here Divisor of 24 = 1 + 2 + 3 + 4 + 6 + 8 + 12 + 24 = 60.

**Also Check:-**Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.

Tip:- Copy the colored code or full code(According to Requirement ) and paste it into hacker rank editor.All solution provided here are in C++ (CPP) if any reader wants these solutions in C, and Java comments below or Email me with your query like " day n solution in C / C++ / Java. Check the end of the post solutions with the full explanation

**Submit Your Solution Here:-**Click Here

**Solution:-**

#include <cmath>

#include <cstdio>

#include <vector>

#include <iostream>

#include <algorithm>

#include <string>

using namespace std;

class AdvancedArithmetic

{

public:

virtual int divisorSum(int n)=0;

};

struct Calculator : public AdvancedArithmetic

{

int divisorSum(int n)

{

int total=0,i;

for(i=1; i<=n; i++)

{

if(n%i == 0)

{

total+=i;

}

}

return total;

}

};

int main()

{

int n;

cin >> n;

AdvancedArithmetic *myCalculator = new Calculator();

int sum = myCalculator->divisorSum(n);

cout << "I implemented: AdvancedArithmetic\n" << sum;

return 0;

}

**Output:-**

**You May Also Like:-**

1. Hackerrank Solution For Day 12: Inheritance

2. Hackerrank Solution For Day 13: Abstract Classes

3. Hackerrank Solution For Day 14: Scope

4. Hackerrank Solution For Day 15: Linked List

5. Hackerrank Solution For Day 20: Sorting

6. Hackerrank Solution For Day 21: Generics

7. Hackerrank Solution For Day 22: Binary Search Trees

8. Hackerrank Solution For Day 23: BST Level-Order Traversal

9. Hackerrank Solution For Day 24: More Linked Lists

10. Hackerrank Solution For Day 25: Running Time and Complexity

## 0 Comments: