Maksud3

part4

Nov 26th, 2020
525
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.epam.rd.java.basic.practice1;
  2.  
  3. public class Part4 {
  4.  
  5.     public static int gcd(int firstNumber, int secondNumber) {
  6.         while (firstNumber != secondNumber) {
  7.             if(firstNumber > secondNumber) {
  8.                 firstNumber -= secondNumber;
  9.             } else {
  10.                 secondNumber -= firstNumber;
  11.             }
  12.         }
  13.         return secondNumber;
  14.     }
  15.  
  16.     public static void main(String[] args) {
  17.         System.out.println(gcd(55, 121));
  18.     }
  19.  
  20. }
  21.  
RAW Paste Data