You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
445 B
26 lines
445 B
4 years ago
|
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);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|