Advertisement
Guest User

michael reeves please

a guest
Jan 19th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. package triange;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Gcd {
  6. public static int gcd(int f,int g) {
  7. int c=0;
  8. for (double i = 1; i <= f; i+=1){
  9. if(Math.round(f/i)==(f/i)) {
  10. for (double j = 1; j <= g; j+=1){
  11. if( Math.round(g/j)==g/j && j==i) {
  12. c =(int)Math.round(i);
  13. }
  14. }
  15. }
  16. }
  17. return c;
  18. }
  19. public static void main(String[] args) {
  20. Scanner line = new Scanner(System.in);
  21. System.out.println("num1?");
  22. int num = line.nextInt();
  23. System.out.println("num2?");
  24. int num2 = line.nextInt();
  25. System.out.println(gcd(num,num2));
  26. }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement