12345678910111213141516171819202122232425 |
- #include <stdio.h>
- #include <math.h>
- int main() {
- int n, num = 1;
- double x, ex = 1;
- scanf("%lf %d", &x, &n);
-
- while (num <= n) {
- double factorial = 1;
- int factorialnum = 1;
-
- while (factorialnum <= num) {
- factorial *= factorialnum;
- factorialnum += 1;
- }
-
- ex += pow(x, num) / factorial;
- num += 1;
- }
-
- printf("%.6lf", ex);
-
- return 0;
- }
|