Mahmoud_Hawara

PA07-5

Dec 30th, 2025
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Main {
  4.    
  5.     public static int modulusRec(int x, int y) {
  6.         if (x == 0) return 0;
  7.         if (x < y) return x;
  8.         return modulusRec(x - y, y);
  9.     }
  10.    
  11.     public static void main(String[] args) {
  12.         Scanner sc = new Scanner(System.in);
  13.         int x = sc.nextInt();
  14.         int y = sc.nextInt();
  15.         if (y < 0) {
  16.             System.out.println("Errrrrrror!!!!!!");
  17.             return;
  18.         }
  19.         System.out.println(modulusRec(5, 3));
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment