How to Print 1 to n Without Using Loop /Using Recursive Function In JAVA>?

How to print 1 of n number without using loop ?

The ans is yes:
Print anything to without using loop . Recursive functions do this .Any Number to print  to  the Recursive Functions .

What is Recursive Function ?

Ans:

A recursive function (DEF) is a function which either calls itself or is in a potential cycle of function calls.  
Using a function that calls itself with a decrementing  parameter  counting the times it still has to call itself .



Code:

public class recursive
{
public static void recursive ( int count)
{
if(count==10000)
{  
return;
}

System.out.println("Hello Pain");
   recursive(count+1);
}
public static void main(String[]args)
{
   recursive(0);

}
}

Recursive functions are an inefficient means of solving problems in terms of run times but are interesting to study nonetheless.  
For our purposes we will only consider immediate recursion since this will cause enough difficulty.

Thanks 

*

Post a Comment (0)
Previous Post Next Post