Course of Raku / Essentials / Functions essentials / Creating and calling functions / Exercises

Function to compute xʸ

Problem

Create a function with two arguments that returns the value of $x to the power of $y. Write a program to print the value of 5³, 2¹⁰, and (−4)⁵.

Example

For the above-mentioned values, the program should print:

$ raku function-x-to-the-power-of-y.raku
125
1024
-1024

Solution

✅ See the solution

Course navigation

← Quiz — Functions with default values   |   Solution: Function to compute xʸ →