Skip to content
The Lumenary

Practice · Grades 6–8

Programming for mathematics

Programming for mathematics

Warm-upComputational

What is the value of x after these three lines run?

x = 3
x = x + 4
x = 2 * x

Programming for mathematics

Warm-upComputational

What does the Python line count = count + 1 do?

Choose one

Programming for mathematics

Warm-upHuman

Write the binary number 1101012110101_2 in decimal.

Programming for mathematics

CoreHuman

Write 2626 in binary, without leading zeros. (Type just the digits, for example 101.)

Write elements separated by commas. Order and repeats don’t matter — just like in a set!

Programming for mathematics

CoreComputational

What does this program print?

total = 0
for i in range(1, 6):
    if i % 2 == 1:
        total = total + i
print(total)

Programming for mathematics

CoreComputational

In Python, 0.1 + 0.2 == 0.3 evaluates to False. Why?

Choose one

Programming for mathematics

StretchHuman

The uniqueness proof for binary representations starts: “the last binary digit of nn must be the remainder of nn on division by 22”. Why is that true?

Choose one

Programming for mathematics

CoreComputational

Write to_binary(n) that returns the binary representation of a whole number n as a string without leading zeros, using repeated division by 2 (don't use Python's built-in bin). to_binary(0) should be "0".

Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

Programming for mathematics

StretchComputational

This function is meant to compute 12+22+⋯+n21^2 + 2^2 + \dots + n^2. It runs without any error — but it is wrong. Find and fix the bug. Then check your fixed version against the formula n(n+1)(2n+1)6\tfrac{n(n + 1)(2n + 1)}{6}.

Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

Programming for mathematics

CoreFormal

In the Lean section, which of these machine-checked statements tells you that the sum 1+2+⋯+10001 + 2 + \dots + 1000 equals 1000⋅10012\tfrac{1000 \cdot 1001}{2}?

Choose one