using for loop in Java print first n natural numbers
Answers
Answer:
Java Program to print First N Natural Numbers using Recursion
- public class Natural.
- int n;
- Scanner s = new Scanner(System.
- System. out. print("Enter any number:");
- n = s. nextInt();
- Natural obj = new Natural();
- System. out. print("Natural numbers till "+n+" :");
- obj. natural(n,1);
Heya mate Ur Answer ♦♦♦♦♦♦♦♦♦♦
{
{ public static void main(String[] args)
{ public static void main(String[] args) {
{ public static void main(String[] args) { int n;
{ public static void main(String[] args) { int n; Scanner s = new Scanner(System.in);
{ public static void main(String[] args) { int n; Scanner s = new Scanner(System.in); System.out.print("Enter any number:");
{ public static void main(String[] args) { int n; Scanner s = new Scanner(System.in); System.out.print("Enter any number:"); n = s.nextInt();
{ public static void main(String[] args) { int n; Scanner s = new Scanner(System.in); System.out.print("Enter any number:"); n = s.nextInt(); Natural obj = new Natural();
{ public static void main(String[] args) { int n; Scanner s = new Scanner(System.in); System.out.print("Enter any number:"); n = s.nextInt(); Natural obj = new Natural(); System.out.print("Natural numbers till "+n+" :");
{ public static void main(String[] args) { int n; Scanner s = new Scanner(System.in); System.out.print("Enter any number:"); n = s.nextInt(); Natural obj = new Natural(); System.out.print("Natural numbers till "+n+" :"); obj.natural(n,1);
{ public static void main(String[] args) { int n; Scanner s = new Scanner(System.in); System.out.print("Enter any number:"); n = s.nextInt(); Natural obj = new Natural(); System.out.print("Natural numbers till "+n+" :"); obj.natural(n,1);
{ public static void main(String[] args) { int n; Scanner s = new Scanner(System.in); System.out.print("Enter any number:"); n = s.nextInt(); Natural obj = new Natural(); System.out.print("Natural numbers till "+n+" :"); obj.natural(n,1);
{ public static void main(String[] args) { int n; Scanner s = new Scanner(System.in); System.out.print("Enter any number:"); n = s.nextInt(); Natural obj = new Natural(); System.out.print("Natural numbers till "+n+" :"); obj.natural(n,1); }
{ public static void main(String[] args) { int n; Scanner s = new Scanner(System.in); System.out.print("Enter any number:"); n = s.nextInt(); Natural obj = new Natural(); System.out.print("Natural numbers till "+n+" :"); obj.natural(n,1); } int natural(int y, int i)
{ public static void main(String[] args) { int n; Scanner s = new Scanner(System.in); System.out.print("Enter any number:"); n = s.nextInt(); Natural obj = new Natural(); System.out.print("Natural numbers till "+n+" :"); obj.natural(n,1); } int natural(int y, int i) {
{ public static void main(String[] args) { int n; Scanner s = new Scanner(System.in); System.out.print("Enter any number:"); n = s.nextInt(); Natural obj = new Natural(); System.out.print("Natural numbers till "+n+" :"); obj.natural(n,1); } int natural(int y, int i) { if(i <= y)
{ public static void main(String[] args) { int n; Scanner s = new Scanner(System.in); System.out.print("Enter any number:"); n = s.nextInt(); Natural obj = new Natural(); System.out.print("Natural numbers till "+n+" :"); obj.natural(n,1); } int natural(int y, int i) { if(i <= y) {
{ public static void main(String[] args) { int n; Scanner s = new Scanner(System.in); System.out.print("Enter any number:"); n = s.nextInt(); Natural obj = new Natural(); System.out.print("Natural numbers till "+n+" :"); obj.natural(n,1); } int natural(int y, int i) { if(i <= y) { System.out.print(i+" ");
{ public static void main(String[] args) { int n; Scanner s = new Scanner(System.in); System.out.print("Enter any number:"); n = s.nextInt(); Natural obj = new Natural(); System.out.print("Natural numbers till "+n+" :"); obj.natural(n,1); } int natural(int y, int i) { if(i <= y) { System.out.print(i+" "); return(natural(y,++i));
{ public static void main(String[] args) { int n; Scanner s = new Scanner(System.in); System.out.print("Enter any number:"); n = s.nextInt(); Natural obj = new Natural(); System.out.print("Natural numbers till "+n+" :"); obj.natural(n,1); } int natural(int y, int i) { if(i <= y) { System.out.print(i+" "); return(natural(y,++i)); }
{ public static void main(String[] args) { int n; Scanner s = new Scanner(System.in); System.out.print("Enter any number:"); n = s.nextInt(); Natural obj = new Natural(); System.out.print("Natural numbers till "+n+" :"); obj.natural(n,1); } int natural(int y, int i) { if(i <= y) { System.out.print(i+" "); return(natural(y,++i)); } return 1;
{ public static void main(String[] args) { int n; Scanner s = new Scanner(System.in); System.out.print("Enter any number:"); n = s.nextInt(); Natural obj = new Natural(); System.out.print("Natural numbers till "+n+" :"); obj.natural(n,1); } int natural(int y, int i) { if(i <= y) { System.out.print(i+" "); return(natural(y,++i)); } return 1;
Mark as brainliest ♥♥♦♥♥♦♦♥♦♥♥♦♦♥♦
Hope it's helpful