← Back to challenges

Nth Even Number

PythonMediummathnumberslanguage_fundamentals

Instructions

Create a function that takes a number n and returns the nth even number beginning with 0 as the first.

Examples

nth_even(1) ➞ 0
# 0 is first even number

nth_even(2) ➞ 2
# 2 is second even number

nth_even(100) ➞ 198

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Destructuring Assignment