Editor

Largest Multiple

Advanced · Write the code · from Developing Algorithms: Pseudocode, MOD, and Building Blocks

From the lesson: Developing Algorithms: Pseudocode, MOD, and Building Blocks

An algorithm is a finite set of instructions that accomplishes one specific task, and you can write the same algorithm in plain English, draw it as a flowchart, or type it as code.

Read the lesson

Write max_multiple(numbers, divisor) that returns the largest number in the list that is evenly divisible by divisor. If no number in the list is divisible, return None.

Build it from two algorithms you know: the divisibility check and finding a maximum.

max_multiple([4, 9, 12, 7], 3)  ->  12
max_multiple([5, 11, 13], 2)    ->  None
def max_multiple(numbers, divisor):
# Return the largest number divisible by divisor, or None
pass

What Check runs

Your code runs first, then each of these lines, and 2 more that stay hidden. The output must match exactly.

RunsExpected output
max_multiple([4, 9, 12, 7], 3)12
print(max_multiple([5, 11, 13], 2))None

More Algorithm exercises

All Python exercises · 50 practice problems