Skip to content
The site is in test mode. All features are free for now.
MathAgora

C++ and Mathematics

Basic C++ through mathematical problems, the way it is taught to mathematicians: sums and loops, recursion, the Euclidean algorithm and primes, arrays and progressions, Newton's method and numerical integration. In the exercises you read code and work out what it prints โ€” the best way to build algorithmic thinking.

Your path to the summit starts here. First topic โ€” Variables, types and arithmetic.

Roadmap

Study the topics in this order. Each one builds on the previous.

  1. Step 1 45 min8 questions

    Variables, types and arithmetic

    Structure of a C++ program, int and double, integer division and remainder, operator precedence, type conversion.

    • int vs double
    • Integer division / and remainder %
    • The ++ and += operators
    • Type conversion
    0 of 8 solved
  2. Step 2 50 min8 questions

    Conditions and loops

    if/else, logical operators, for and while loops, sums ฮฃ\Sigma and products in code, nested loops.

    • Computing a sum โˆ‘\sum with a loop
    • Counting with a condition
    • while loops
    • Counting iterations of nested loops
    0 of 8 solved
  3. Step 3 55 min8 questions

    Functions and recursion

    Defining and calling functions, pass by value vs by reference, recursion: factorial, Fibonacci, fast power, digit sum.

    • Function composition f(f(x))f(f(x))
    • int x vs int &x
    • Base case and recursive step
    • Fast exponentiation
    0 of 8 solved
  4. Step 4 60 min8 questions

    Number theory in code

    The Euclidean algorithm, GCD and LCM, primes, divisors, digits and modular arithmetic.

    • The Euclidean algorithm
    • Primality test up to n\sqrt n
    • Sum of divisors
    • Remainders of powers
    0 of 8 solved
  5. Step 5 50 min8 questions

    Arrays, vectors and sequences

    Arrays and vector, zero-based indexing, sum, maximum, prefix sums, progressions, sorting.

    • Zero-based indexing
    • Finding the maximum
    • Prefix sums
    • sort and sequences
    0 of 8 solved
  6. Step 6 60 min8 questions

    Numerical methods

    Floating-point precision, <cmath>, Newton's method, bisection, numerical integration and series approximations.

    • Comparing doubles with a tolerance
    • Newton's method for 2\sqrt2
    • The bisection method
    • Trapezoidal rule and approximating ee
    0 of 8 solved