Content deleted Content added
→Programming example: PEP-8 |
|||
Line 320:
==Programming example==
The example below searches for polydivisible numbers in [[Python (programming language)|Python]].
<source lang="python">
def find_polydivisible(base: int) -> List[int]:
numbers = []
previous = []
for i in range(1, base):
previous.append(i)
new = []▼
digits = 2▼
while not previous == []:▼
numbers.append(previous)▼
for i in range(0, len(previous)):▼
for j in range(0, base):▼
number = previous[i] * base + j▼
if number % digits == 0:▼
new.append(number)▼
previous = new▼
new = []
digits =
▲ while not previous == []:
return numbers▼
▲ numbers.append(previous)
▲ for i in range(0, len(previous)):
▲ for j in range(0, base):
▲ number = previous[i] * base + j
▲ if number % digits == 0:
▲ new.append(number)
▲ previous = new
▲ new = []
▲ return numbers
</source>
|