From a8669e83854835bbac1173097639c378c8e0b296 Mon Sep 17 00:00:00 2001 From: Ozhao <2577760571@qq.com> Date: Thu, 6 Aug 2020 20:10:00 +0800 Subject: [PATCH] Mjs --- Mys.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Mys.txt diff --git a/Mys.txt b/Mys.txt new file mode 100644 index 0000000..e738da3 --- /dev/null +++ b/Mys.txt @@ -0,0 +1,25 @@ +import java.util.Scanner; + +public class duishu { + public static void main(String args[]) { + double x,k=1,f=1,e,n,a=0; + Scanner sc = new Scanner(System.in); + x=sc.nextDouble(); + n=sc.nextDouble(); + if(n < 0) + System.out.println("error"); + else + { + for(int i = 1;i <= n;i++) + { + + a =Math.pow((double)x,(double)i); + k = k*i; + e = a/k; + f += e; + } + System.out.println((double)f); + } + } + +}