What's new

# Python to java code

#### HELP NYO PO AKO

##### Leecher
Pa help naman po paano convert ito convert into a java code...

Contributor
wow recursion.

#### 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:

#### HELP NYO PO AKO

##### Leecher
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

#### FreeAllYouCan-OFFICIAL

##### Leecher
Contributor
lods eto lumabas sa iyong codes
yes because recursion catches an exception naka indicate sa java division by zero is error baka sa python code mismo ang error,

#### HELP NYO PO AKO

##### Leecher
Guys baka alam niyo po bakit error sa tail recursion help mga lodi

#BBM2022

Replies
3
Views
146
Replies
6
Views
220
Replies
19
Views
381
Replies
0
Views
101
Replies
3
Views
117

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