Algebra

I am going to assume that you are already aware of the topics in this lesson. However, I will go over them briefly to brush up and as a reference if and when you need them.

Natural numbers

All positive integers starting from 11 1,2,3,4,5,6,7,8,...1, 2, 3, 4, 5, 6, 7, 8, ...


Sum

Sum of first nn natural numbers is n(n+1)2\frac{n*(n+1)}{2}


Factorial

Denoted by the exclamation mark symbol.

n! is called n factorial and its value is defined as:

n!=1×2×3×...×nn! = 1 \times 2 \times 3 \times ... \times n

i.e., n! is the product of the first n natural numbers.


Factors and multiples

Factors: A factor of a number is a smaller or equal number such that it divides the number exactly and gives the remainder zero. For example:

Factors of 121,2,3,4,6,1212 \to 1, 2,3,4,6,12 Multiples: A multiple of a number, nn, is a larger number such that the nn is a factor of that number. For example:

Multiples of 44,8,12,16,...4 \to 4, 8, 12, 16, ...


Prime numbers

Prime numbers are natural numbers greater than 1 that cannot be expressed as a product of two smaller natural numbers.

They are natural numbers greater than 1 with only two factors, 1 and the number itself.

2,3,5,7,11,...2, 3, 5, 7, 11, ...

Note: A good estimation of the number of primes <N<N is logNlogN. This is useful for complexity analysis.


Modulus operator

The modulus operation between two integers, a % b, returns the remainder when a is divided by b. For example:

5%2=15 \% 2 = 1

100%89=11100 \% 89 = 11

2%5=22 \% 5 = 2

9%3=09 \% 3 = 0

21%21=021 \% 21 = 0

The result of the modulus operator is 00 if a is a multiple of b.

We can easily check if a number is even with if if (x % 2 == 0).


In the next lesson, we’ll go over set theory, definitions and basic operations.

Get hands-on with 1400+ tech skills courses.