Course of Raku / Addendum 🆕 / Working with data / Numbers and mathematics / Exercises

Perfect numbers

Problem

A perfect number equals the sum of its proper divisors (every divisor except the number itself). For example, 6 = 1 + 2 + 3. Find and print all perfect numbers from 1 to 30.

Example

The program prints:

[6 28]

Solution

See the solution

Course navigation

Numbers and mathematics   |   Solution: Perfect numbers