package com.test.common;
public class TestE {
public static double getE(int x)
{
int ncount=1;
int xcount=x;
double count=1;
int n=1;
while(n<10)
{
ncount=ncount*n;
xcount=xcount*x;
count+=(double)xcount/(double)ncount;
n++;
}
return count;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(getE(2));
}
}
求e^x的近似值
最新推荐文章于 2024-01-02 13:17:02 发布