Flowchart (ISO 5807)
Source code
Java
class Amicable {
static int sumDivisors(int n) {
int s = 0;
for (int i = 1; i < n; i++) {
if (n % i == 0) {
s += i;
}
}
return s;
}
static boolean areAmicable(int a, int b) {
return sumDivisors(a) == b && sumDivisors(b) == a;
}
}The editor opens with this code — change it and the chart redraws.
- Language
- Java
- Constructs
- sum of divisors
- Topic
- Algorithms
- Formats
- Word, Visio, draw.io, PDF, SVG