i have this program
public static int p(int n, int m){
if(n==m) return n;
if (n<m) return p(n,m-n);
else return p(n-m,m);
}
how to put this program on iterative program with while loop. Thanks
i have this program
public static int p(int n, int m){
if(n==m) return n;
if (n<m) return p(n,m-n);
else return p(n-m,m);
}
how to put this program on iterative program with while loop. Thanks
Copyright © 2021 Jogjafile Inc.
This code substacts the smaller of the two inputs from the larger until they are equal. This can be done with a while loop: