Created
December 14, 2021 19:13
-
-
Save Arjun2002tiwari/2ffd0725ba5fdc5c6e9ac132041d4522 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
interface AdvanceArithmetic{ | |
int divi_sum(int n); | |
} | |
public class MyCalculator implements AdvanceArithmetic { | |
public int divi_sum(int n) { | |
int sum = 0; | |
for (int i = 1; i <= n; i++) { | |
int rem = n % i; | |
if (rem == 0) { | |
sum = sum + i; | |
} | |
} | |
return sum; | |
} | |
public static void main(String[] args) { | |
MyCalculator obj = new MyCalculator(); | |
Scanner sc = new Scanner(System.in); | |
int n = sc.nextInt(); | |
int sum = obj.divi_sum(n); | |
System.out.println(sum); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment