DNPotapov / Codewars-katas-

0 stars 0 forks source link

Polydivisible Numbers (7 kyu) #19

Open DNPotapov opened 1 year ago

DNPotapov commented 1 year ago
def polydivisible(x):
    count = 1
    mass = []
    for index,item in enumerate(str(x)):
        mass.append(item)
        chislo = int(''.join((str(i) for i in mass)))
        if chislo % count == 0:
            count += 1
        else:
            return False
    return True
DNPotapov commented 1 year ago

A polydivisible number is divisible in an unusual way. The first digit is cleanly divisible by 1, the first two digits are cleanly divisible by 2, the first three by 3, and so on.

DNPotapov commented 1 year ago

https://www.codewars.com/kata/5e4217e476126b000170489b