Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class PowAndFactorial
- {
- public static void main(String []args)
- {
- Scanner UI = new Scanner(System.in);
- System.out.println("Insert your desirable number");
- int num1 = UI.nextInt();
- System.out.println("Insert the number of power you want");
- int pow = UI.nextInt();
- for(int i = 1; i <= pow; i++)
- {
- num1 = num1 * i;
- }
- System.out.println("The result of the power is " + num1);
- System.out.println();
- System.out.println("Insert the number you want to start from");
- int result = UI.nextInt();
- int repeat = result;
- for(int i = 1; i < repeat; i++)
- {
- result = result * i;
- }
- System.out.println("The result is " + result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement