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

Odd or even

Problem

Create a function that takes an integer number as an argument and returns the string 'Odd' or 'Even'. Write a program that uses this function to print the property of a few numbers, for example, 10, 5, 0, and 3.

Example

For the given numbers, the program is expected to print the following:

$ raku odd-or-even.raku
Even
Odd
Even
Odd

Solution

See the solution

Next exercise

💪 Recursive factorial

Course navigation

Associative data types / Interpolating hashes   |   More about functions