From df91a4dd57f09a71c5c6690765e560b1c52777a9 Mon Sep 17 00:00:00 2001 From: zhangzheng Date: Thu, 6 Aug 2020 18:16:08 +0800 Subject: [PATCH] e.txt --- e.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 e.txt diff --git a/e.txt b/e.txt new file mode 100644 index 0000000..d802316 --- /dev/null +++ b/e.txt @@ -0,0 +1,25 @@ +package e的x次方; +public class power{ + +public static int factorial(int n){ + int factorial=1; + int counter=1; + while (counter<1+n){ + factorial*=counter+1; + counter++; + } + return factorial; + } +public static double ex(int n,int x){ + double ex=1.0; + int counter=1; + while (counter<=n){ + ex+=(double)Math.pow(x,counter)/factorial(counter); + counter++; + } + return ex; +} + + + +} \ No newline at end of file