Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package individual_project2;
- import java.math.BigInteger;
- public class GCD {
- //Default Constructor
- public GCD(){
- }
- //GC Constructor which calls the gcd method to print the Greatest Common Divisor Number
- //but only if both of the numbers are integer (check also InputOutput.class, Line 35)
- public GCD(int a, int b){
- gcd(a,b);
- }
- public void gcd(int a, int b){
- BigInteger b1 = new BigInteger(""+a);
- BigInteger b2 = new BigInteger(""+b);
- BigInteger gcd = b1.gcd(b2);
- System.out.println("The Greatest Common Divisor Number of " + a + " and " + b + " is: " + gcd.intValue());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement