What's new

Python to java code

FreeAllYouCan-OFFICIAL

Leecher
Contributor
import java.util.*;

public static int find_gcd(int n1, int n2)
{
if(n1 %n2 == 0)
return n2;
else
return find_gcd(n2,(n1%n2));
}
pubic static void main(String[] args) {
int n1,n2;
Scanner kbd = new Scanner(System.in);
System.out.println("Enter 1st number: ");
n1 = kbd.nextInt();
System.out.println("Enter 2nd number: ");
n2 = kbd.nextInt();
System.out.println("The GCD of " + n1 + " and " + n2 + " is " + find_gcd(n1,n2));
}
 
Last edited:
import java.util.*;

public static int find_gcd(int n1, int n2)
{
if(n1==n2)
return n2;
else
return find_gcd(n2,(n1%n2));
}
pubic static void main(String[] args) {
int n1,n2;
Scanner kbd = new Scanner(System.in);
System.out.println("Enter 1st number: ");
n1 = kbd.nextInt();
System.out.println("Enter 2nd number: ");
n2 = kbd.nextInt();
System.out.println("The GCD of " + n1 + " and " + n2 + " is " + find_gcd(n1,n2));
}
lods eto lumabas sa iyong codes
 

Attachments

Online statistics

Members online
1,649
Guests online
1,288
Total visitors
2,937

Forum statistics

Threads
1,239,009
Posts
21,711,668
Members
1,618,027
Attachments
1,746,241
Profile posts
100,394
Top