Course of Raku / Essentials / Functions essentials / Creating and calling functions / Exercises
The value of e
Problem
Create a function that computes an approximate value of the mathematical constant e using the following formula:

This function should allow being called in one of the forms:
- The argument defines the number of items in the formula:
e-approx(10). - If no argument is passed, the sum contains 100 elements:
e-approx().
Print the results for both cases.
Example
$ raku the-value-of-e.raku
2.7182818
2.718281828459045Solution
Course navigation
← Solution: Function table | Solution: The value of e →
Translations of this page: English • Deutsch • Español • Italiano • Latviešu • Nederlands • Български • Русский • Українська