# Thread: basic help with Recursive

1. Member Join Date
Sep 2009
Location
http://www.kouje.com
Posts
16
Rep Power
0

## basic help with Recursive

I'm trying to use Recursive, I know how to use it and i understand it, but the problem i have is that i have to use 2 input variables, and I don't know how to mix them both.

My program should take a number, add an exponential number (user inputed) and do the math.
This program work, but i have no idea where to add the 2nd input. help pls :(

Java Code:
```import java.util.Scanner;

public class testing1
{
public static void main( String [] args )
{
Scanner kb = new Scanner(System.in);

// Get number.
System.out.print("Enter number: ");
num1 = kb.nextInt();

// Get exponential number.
System.out.print("Enter exponential number: ");
num2 = kb.nextInt();

// compute and output it.
System.out.println(num1 + "^" + num2+ " is: " + factorial(num1));
}

public static int factorial( int n )
{
if ( n <= 0 )  // base case
return 1;
else    // general case
return ( n * factorial ( n - 1 ) );
}
}```  Reply With Quote

2. ## I don't see a need for factorialization here, but rather a power function.  Reply With Quote

3. Member Join Date
Sep 2009
Location
http://www.kouje.com
Posts
16
Rep Power
0

## i know, but that's wat the instructor wants.  Reply With Quote

4. ## This doesn't make sense on two grounds:
1) The equation shown is a power equation, and
2) A factorialization method by its nature always takes one and only one parameter.

Are you sure that you didn't misread or mis-interpret the instructions/  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•