Java - Print with Recursion

Description

Print with Recursion

Demo

import java.util.Scanner;

public class Recursion {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int inputNumber = scn.nextInt();

        PrintRecursion(inputNumber);/*w ww . j  a va2 s .co m*/
    }



    public static void PrintRecursion(int n) {
        if (n < 1) {
            return;
        }
        PrintRecursion(n-1);
        System.out.print(n + " ");
    }
}

Related Topic