Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,17 @@ | ||
package CodingNinja.recursion; | ||
|
||
public class printNumbers1toN { | ||
|
||
public static void printNum(int n) { | ||
if (n == 0) // base case | ||
return; | ||
|
||
printNum(n - 1); // recursive call | ||
|
||
System.out.println(n); | ||
} | ||
|
||
public static void main(String[] args) { | ||
printNum(5); | ||
} | ||
} |