Jhonny_V

Calculate Complex Sum

Sep 28th, 2020
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1. package com.company;
  2. import java.util.Scanner;
  3. import java.lang.Math;
  4. public class Main {
  5.  
  6.     public static void main(String[] args) {
  7.     Scanner s = new Scanner(System.in);
  8.         int N = s.nextInt();
  9.         double x = s.nextDouble();
  10.         int factorial = 1;
  11.         double divisor = 1;
  12.         double S = factorial/divisor;
  13.         for (int i=1;i<=N;i++){
  14.             factorial = factorial*i;
  15.             divisor = Math.pow(x,i-1);
  16.             S += S;
  17.         }
  18.         System.out.println(S);
  19.  
  20.     }
  21.  
  22. }
  23.  
  24.  
  25.  
  26.  
Advertisement
Add Comment
Please, Sign In to add comment