/python/grains/grains.py

1
2
3
4
5
6
7
8
9
10
11
12
def on_square(n):
    """
    Return number of grains on square number n (1-based)
    """
    return 2**(n-1)


def total_after(n):
    """
    Return total number of grains after n squares
    """
    return 2**n - 1

Comments


You're not logged in right now. Please login via GitHub to comment