衍 GreatestCommonDivisorMethod . java1 iaport java . util . Scanner ;23 public class CreatestCommonDivisorMethod { 182 第 6 章4 / * * Main method * /5 public static void main ( String [ ] args ) {6 / / Create a Scanner7 Scanner input « new Scanner ( System . in ) ;89 // Prompt the user to enter two integers10 System . out . print ( " Enter first integer : • ’ ) ;11 int nl ■ input . nextlntC ) ;12 System . out . print ( " Enter second integer : " ) ;13 int n 2 = input . nextlnt ( ) ;1415 System . out . println ( MThe greatest common divisor for ’ + nl +16••and• •+ n 2 +• • is • •+ gcd ( nl , n 2 ) ) ;17 }1819 / * * Return the gcd of two integers * /20 public static int gcd ( int nl , int n 2 ) {21 int gcd■ 1 ; / / Initial gcd is 122 int k = 2 ; // Possible gcd2324 while ( k < > nl & & k < ■ n 2 ) {25 1 f ( nl % k = = 0 & & n 2 % k = = 0 )26 gcd * k ; // Update gcd27 k + + ;28 }2930 return gcd ; // Return gcd31 }32 }Enter first integer : 45 卜 * «^_Ent