Advertisement
16112

Алгоритъм на Евклид чрез рекурсия

Mar 17th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.21 KB | None | 0 0
  1. public class evklid {
  2.     static int gcd(int a, int b) {
  3.         if (b == 0) {
  4.             return a;
  5.         } else {
  6.             return gcd(b, a / b);
  7.         }
  8.     }
  9.  
  10.     public static void main(String[] args) {
  11.         System.out.println(gcd(10, 10));
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement