Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- double euler_approximation(unsigned int iterations);
- int main(void) {
- int iterations_amount;
- scanf("%d", &iterations_amount);
- printf("Result: %lf", euler_approximation(iterations_amount));
- return 0;
- }
- double euler_approximation(unsigned int iterations) {
- unsigned int fact = 1; // 0!
- double euler = 0;
- for (size_t i = 1; i <= iterations; i++) {
- euler += 1.0 / fact;
- fact *= i;
- }
- return euler;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement