Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. public class Zad2 {
  2.     public static void main(String[] args) {
  3.  
  4.         printAll(10);
  5.  
  6.     }
  7.  
  8.     public static void printAll (int a) {
  9.         if (a % 2 == 0) {
  10.             if (a == 2) {
  11.                 System.out.print(a);
  12.             } else {
  13.                 System.out.print(a + " ");
  14.                 printAll(a - 2);
  15.             }
  16.         } else {
  17.             if (a == 1) {
  18.                 System.out.print(a);
  19.             } else {
  20.                 System.out.print(a + " ");
  21.                 printAll(a - 2);
  22.             }
  23.  
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement