i need help on making a GCF/LCM program for a lab due on tuesday. it has to somehow utilize loops(do/while and possibly if/then-else statements) and modulating. im really confused about how to go and do this, so i came here to look for help
http://en.wikipedia.org/wiki/Euclidean_algorithm just implement the pseudo code to whatever language you are using.
Code: public class GCF { public static int Euclidean(int a, int b) { while(b != 0) { if (a > b) a = a - b; else b = b - a; } return a; } public static void main(String args []) { System.out.println("The GFC of 5 and 6 is " + Euclidean(5, 6)); } } something like this?
hmm looks like i can get it from my friend because ive saved his ass on HW assignments quite a few times lol. but i dont think i could use that because even though it may work, we havent learned the direct way of using 'Euclidean' to get it.