Advertisement
GameNCode

LironWork

Dec 18th, 2015
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PowAndFactorial
  4. {
  5. public static void main(String []args)
  6. {
  7. Scanner UI = new Scanner(System.in);
  8. System.out.println("Insert your desirable number");
  9. int num1 = UI.nextInt();
  10. System.out.println("Insert the number of power you want");
  11. int pow = UI.nextInt();
  12. for(int i = 1; i <= pow; i++)
  13. {
  14. num1 = num1 * i;
  15. }
  16. System.out.println("The result of the power is " + num1);
  17. System.out.println();
  18. System.out.println("Insert the number you want to start from");
  19. int result = UI.nextInt();
  20. int repeat = result;
  21. for(int i = 1; i < repeat; i++)
  22. {
  23. result = result * i;
  24. }
  25. System.out.println("The result is " + result);
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement