Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- import java.lang.Math;
- public class Main {
- public static void main(String[] args) {
- Scanner s = new Scanner(System.in);
- int N = s.nextInt();
- double x = s.nextDouble();
- int factorial = 1;
- double divisor = 1;
- double S = factorial/divisor;
- for (int i=1;i<=N;i++){
- factorial = factorial*i;
- divisor = Math.pow(x,i-1);
- S += S;
- }
- System.out.println(S);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment