Chain of powers

You have to program the function @short_power7_chains@ below. Remember that 1 is a power of 7: 70=17^0 = 1. The following auxiliar function may be helpful.

def is_power7(n):
    '''
    Requires a non negative integer n.
    Returns True when n is a power of 7
    Returns False when n is not a power of 7
    '''
    if n == 0:
        return False
    while n != 1:
        if n%7 != 0:
            return False
        n = n//7
    return True

Scoring

The function counts 100 points.

Sample session

Problem information

Author: ProAl

Generation: 2026-01-25T19:33:35.731Z

© Jutge.org, 2006–2026.
https://jutge.org