Loops coding challenges

Practise loops with 58 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 · 36 Medium · 22

Skills you'll practise: Nested loopsSymmetryDigit sumPaddingRecurrencesSieve of EratosthenesSquare root boundBit shiftsConditionsDigit extractionDivisibilityDivisor pairs
  • 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.

58 challenges
Easy

Prime Number Check

Decide whether a number is prime.

You'll learn DivisibilityLoop optimization
BeginnerLoopsNumbersStudent-beginner
Easy

Fibonacci Number

Return the n-th Fibonacci number.

You'll learn IterationUpdating two variables
BeginnerLoopsSequencesStudent-beginner
Easy

Halve Until One

Count how many halvings bring a number down to 1.

You'll learn While loopsCounting
BeginnerLearning-pathLoops
Easy

Sum of Odd Numbers

Add every odd number up to a limit.

You'll learn For loopsAccumulators
BeginnerLearning-pathLoops
Easy

Countdown to Liftoff

Count down from a number and end with Liftoff!

You'll learn Reverse loopsLists
BeginnerLearning-pathLoops
Easy

Power by Repeated Multiplication

Raise a number to a power with a loop.

You'll learn Running productZero exponent
BeginnerLearning-pathLoops
Easy

Multiplication Table Row

List the first multiples of a number.

You'll learn MultiplesBuilding lists
BeginnerLearning-pathLoops
Easy

Flatten a 2D Array

Combine the rows of a 2D integer array into one array.

You'll learn 2D arraysNested loops
ArraysLoops
No solutions yet
Easy

Integer Square Root

Find the largest whole number whose square does not exceed n, without a square root function.

You'll learn Binary searchInteger overflow
BeginnerBinary-searchCS1High schoolLoopsNumbersmath
No solutions yet
Medium

Decode the Pattern

Work out the rule behind a family of letter squares from its first members, then build the member for any n.

You'll learn Pattern analysisGrid coordinates
CS1High schoolIntermediateLoopsNested-loopsPatterns
No solutions yet
Medium

Reverse the Bits

Reverse the order of the lowest width bits of a number.

You'll learn Bit shiftsBit masks
Bit manipulationCS1High schoolIntermediateLoopsNumbersmath
No solutions yet
Easy

Base Converter

Convert a number written in one base (2 to 36) to another base.

You'll learn Positional notationRepeated division
BeginnerCS1High schoolLoopsNumbersmath
No solutions yet
Easy

Binary Triangle

Print a right triangle of alternating 1s and 0s where each row starts with the opposite digit of the row above.

You'll learn Nested loopsParity
BeginnerBit manipulationCS1High schoolLoopsNested-loopsPatterns
No solutions yet
Medium

Diamond Pattern

Print a solid diamond of stars made of a pyramid and its mirror image.

You'll learn Nested loopsSymmetry
CS1High schoolIntermediateLoopsNested-loopsPatterns
No solutions yet
Easy

Binomial Coefficient

Count the ways to choose k items out of n (n choose k).

You'll learn Pascal's triangleOverflow-safe arithmetic
BeginnerCS1High schoolLoopsNumbersmath
No solutions yet
Easy

Perfect Square Check

Decide whether an integer is the square of a whole number.

You'll learn Integer square rootEdge cases
BeginnerCS1High schoolLoopsNumbersmath
No solutions yet
Medium

Prime Factorization

Break a number into its prime factors, listed from smallest to largest with repetition.

You'll learn Trial divisionSquare root bound
CS1High schoolIntermediateLoopsNumber-theoryNumbersPrimesmath
No solutions yet
Easy

Checkerboard Pattern

Draw a checkerboard of # and . cells with the given number of rows and columns.

You'll learn Nested loopsParity
BeginnerCS1GridsHigh schoolLoopsMatricesNested-loopsPatterns
No solutions yet