All challenges

Thursday, 19 November 2026

Past

Three rungs, one idea. Solving rung 1 counts. Climb as far as you can.

Finding Factors

loops + factors

Rung 1Daily goal5 points

List the factors

Write a function called list_factors

A factor of n is a number that divides into n exactly, with nothing left over. Return a list of all the factors of n, smallest first. The number 12 gives [1, 2, 3, 4, 6, 12]. The number n is always 1 or more.

Examples

InputOutput
12[1, 2, 3, 4, 6, 12]
1[1]
7[1, 7]
16[1, 2, 4, 8, 16]

There are extra hidden tests, so make it work in general, not just for these.

Rung 2Bonus7 points

Is it prime

Write a function called is_prime

A prime number has exactly two factors: 1 and itself. Return True if n is prime and False if it is not. 7 is prime, but 8 is not because 2 goes into it. The number 1 has only one factor, so it is not prime. The number n is always 1 or more.

Examples

InputOutput
7True
8False
1False
2True

There are extra hidden tests, so make it work in general, not just for these.

Rung 3Bonus10 points

The biggest shared factor

Write a function called biggest_shared

Return the biggest number that is a factor of both a and b. For 12 and 18, the factors of 12 are 1, 2, 3, 4, 6 and 12, and the factors of 18 are 1, 2, 3, 6, 9 and 18, so the biggest one they share is 6. Both numbers are always 1 or more, and either one may be the bigger. Two numbers that share nothing else still share 1.

Examples

InputOutput
12, 186
7, 51
10, 1010
1, 91

There are extra hidden tests, so make it work in general, not just for these.

Finish Rung 1 and today counts. Rungs 2 and 3 are there if you want to push further.