Math coding challenges

Practise math with 76 coding challenges, from easy to hard. Every challenge runs in your browser with instant tests, an AI review of your code and community solutions to compare.

Easy · 37 Medium · 36 Hard · 3

Skills you'll practise: Big number arithmeticPrimality testingCycle detectionDigit sumModular arithmeticRecurrencesSieve of EratosthenesSquare root boundBit shiftsCombinatoricsDigit extractionDigit manipulation
  • Python · C++ · C#
  • Automated tests
  • AI code review
  • Community solutions
341
Challenges
245
Solutions shared
9
Languages

All challenges

Search by name or topic, or filter by difficulty.

76 challenges
Medium

Sum of Big Numbers

Add up a list of numbers too long for any built-in integer type.

You'll learn Big number arithmeticString processing
Big integersCompetitive-programmingIntermediateNumber-theoryProject Euler stylemath
No solutions yet
Easy

Lucas Numbers

Return the nth Lucas number, the Fibonacci-like sequence that starts 2, 1.

You'll learn LoopsRecurrences
BeginnerCS1High schoolLoopsNumbersmath
No solutions yet
Medium

Circular Primes

Count the primes up to a limit whose every digit rotation is also prime.

You'll learn Primality testingDigit rotation
Competitive-programmingIntermediateNumber-theoryPrimesProject Euler stylemath
No solutions yet
Medium

Quadratic Primes

Find the quadratic n² + an + b that gives the longest run of primes from n = 0.

You'll learn Primality testingBrute-force search
Competitive-programmingIntermediateNumber-theoryPrimesProject Euler stylemath
No solutions yet
Medium

Catalan Numbers

List the Catalan numbers C(0) to C(n).

You'll learn Dynamic programmingRecurrences
CS1Dynamic-programmingHigh schoolIntermediateLoopsNumbersmath
No solutions yet
Medium

Counting Sundays

Count the months in a range of years that begin on a Sunday.

You'll learn Date arithmeticModular arithmetic
Competitive-programmingDates and timesIntermediateNumber-theoryProject Euler stylemath
No solutions yet
Medium

Integer to Roman

Write a whole number from 1 to 3999 as a Roman numeral.

You'll learn Greedy algorithmsLookup tables
CS1High schoolIntermediateLoopsNumbersmath
No solutions yet
Hard

Non-Abundant Sums

Add up the numbers up to a limit that cannot be written as the sum of two abundant numbers.

You'll learn Divisor sievePair enumeration
AdvancedCompetitive-programmingNumber-theoryPrimesProject Euler stylemath
No solutions yet
Medium

Number Letter Counts

Count the letters needed to write every number from 1 to n in English words.

You'll learn String buildingBreaking numbers into parts
Competitive-programmingIntermediateNumber-theoryProject Euler stylemath
No solutions yet
Easy

Tribonacci

Return the nth tribonacci number, where each term is the sum of the three before it.

You'll learn LoopsRolling variables
BeginnerCS1High schoolLoopsNumbersmath
No solutions yet
Medium

Pentagonal Pair

Count pairs of pentagonal numbers whose sum is pentagonal too.

You'll learn Integer square rootsPair enumeration
Competitive-programmingIntermediateNumber-theoryProject Euler stylemath
No solutions yet
Easy

Sum of Proper Divisors

Add up every divisor of n that is smaller than n.

You'll learn Divisor pairsSquare root bound
BeginnerCS1High schoolLoopsNumber-theoryNumbersPrimesmath
No solutions yet
Medium

Euler's Totient

Count the integers from 1 to n that share no common factor with n.

You'll learn Prime factorizationProduct formula
CS1High schoolIntermediateLoopsNumber-theoryNumbersPrimesmath
No solutions yet
Medium

Highly Divisible Triangular Number

Find the first triangular number that has at least d divisors.

You'll learn Prime factorizationDivisor counting
Competitive-programmingIntermediateNumber-theoryProject Euler stylemath
No solutions yet
Easy

Happy Number

Decide whether repeatedly summing the squares of the digits of a number reaches 1.

You'll learn Digit extractionCycle detection
BeginnerCS1High schoolLoopsNumbersmath
No solutions yet
Easy

Strong Number

Check whether a number equals the sum of the factorials of its digits.

You'll learn Digit extractionFactorials
BeginnerCS1High schoolLoopsNumbersmath
No solutions yet
Medium

Kaprekar Number

Check whether the square of a d-digit number splits into a left part and a d-digit right part that add up to the number.

You'll learn Splitting numbersPowers of ten
CS1High schoolIntermediateLoopsNumbersmath
No solutions yet
Easy

Automorphic Number

Check whether the square of a number ends with the number itself.

You'll learn Digit comparisonPowers of ten
BeginnerCS1High schoolLoopsNumbersmath
No solutions yet