Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class app {
- public static void main(String[] args) {
- var result = gcd(8, 4);
- System.out.println(result);
- }
- public static int gcd(int a, int b) {
- if (b == 0) {
- return a;
- }
- if (a < 0 || b < 0) {
- return -1;
- }
- return gcd(b, a % b);
- }
- }
- // euclidian gdc(a,b) = gdc (b, a mod b)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement