Natural_Nos

public class Recursive_Natural
{
public static void main(int n)
{
System.out.print(sum(n));

}

public static int sum(int x)
{
if(x==0)
return 0;

else
return(x + sum(x-1));
}

}

Advertisements