Contains some sample algorithms That I wrote and thought of publishing. This post will be updated from time to time,depending on the rate I write them. Hope this will be useful to someone.The Language I've used here in writing these algorithms is Java.
1. Euclid's Algorithm to Find the GCD (Greatest Common Divisor)
1. Euclid's Algorithm to Find the GCD (Greatest Common Divisor)
private int findGcd(int m, int n) {
do {
if (m > n) {
m = m - n;
}
if (n > m) {
n = n - m;
}
if (m == n) {
m = m - n;
}
} while (m > 0);
return n;
}
No comments:
Post a Comment