void setup() {
background(2);
size(100, 100);
textSize(20);
text(gcd(100, 67), 20, 40);
text(lcd(100, 67), 20, 70);
}
int gcd(int n, int c) {
if (n==0) {
return c;
}
if (c==0) {
return n;
}
if (n<c) {
return gcd(n, c%n);
}
else {
return gcd(c, n%c);
}
}
int lcd(int n, int c) {
int lcd=n*c/gcd(n, c);
return lcd;
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น