Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Task {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int n = sc.nextInt(), m = sc.nextInt();
- if (m > 0)
- System.out.println(power(n,m));
- else System.out.println((double)1 / power(n,-m));
- }
- public static int power(int x, int y) {
- if (y == 0)
- return 1;
- else
- return x * power(x, y-1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment