[Python] Solution doesn't match the answers

Discussão em 'Python' iniciado por Stack, Julho 24, 2025.

  1. Stack

    Stack Membro Participativo

    The question is:

    Determine the number of natural six-digit numbers that do not contain the number 4 in their record, which can be represented as the sum of an odd number dividing by 109 without remainder, and the natural power of the number 3

    Answers: 1)23124 2)24712 3)25902 4)26444

    I keep getting 22138. Maybe the answers are not correct?

    count = 0
    for a in range(109, 999999, 109):
    if a % 2 == 0:
    continue
    b = 1
    while True:
    n = a + (3**b)
    if n > 999999:
    break
    if n >= 100000 and (str(n).count('4')<1):
    count += 1
    b += 1
    print(count)

    Continue reading...

Compartilhe esta Página