dsa/Recursion/PrintNtoMUsingBacktracking....

21 lines
510 B
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// write a code to print N to one using recursion and function in java using backtracking
class PrintNtoMUsingBacktracking {
static void func(int i, int n){
// Base Condition.
if(i<n) return;
// Function call to print(n-1) integers.
func(i-1,n);
System.out.println(i);
}
public static void main(String[] args) {
// Here, lets take the value of n to be 4.
int n = 8;
func(n,4);
}
}