Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ComplexSum {
- public static void main(String[] args) {
- // S=1+1!/x+2!/x^2+⋯+N!/x^N
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- double x = Double.parseDouble(scanner.nextLine());
- int result = 1;
- for (int i = 1; i <= n; i++) {
- result = result * i;
- // System.out.print(result);
- double xn = result/(Math.pow(x, i));
- // System.out.println(xn);
- double sum = 1+(xn);
- System.out.printf("%.5f", sum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement