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,763
Guests online
1,754
Total visitors
3,517

Forum statistics

Threads
1,233,730
Posts
21,654,121
Members
1,616,427
Attachments
1,738,350
Profile posts
100,321
Top