GCD

import java.util.*; public class MrMemmo { Scanner sc = new Scanner(System.in); public MrMemmo(){ System.out.print("your GCD is" +gcd()); } public int gcd(){ int num =1; System.out.println("Whats yout first number"); int x = sc.nextInt(); System.out.println("Whats yout second number"); int y = sc.nextInt(); for(int i = 1; i <= x; i++){ if(x%i==0 && y%i==0){ num=i; } } return num; } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.