Table of Contents
Even and Odd Numbers
Even numbers are when division by 2 the remainder is 0
Odd Numbers are when division by 2 the remainder is 1
Code snippet to identify Even and Odd Numbers
What does this mean?
Based on the parity of both functions. This means we can separate them into separate sets. Where The Set of Even Numbers has a Parity of 0. Where The Set of Oddd Numbers has a Parity of 1.
A number is divisible by 2 if it's last digit is even.
A number is divisible by 3 if it's a multiple of 3.
A number is divisible by 4 if it's a multiple of 4.
A number is divisible by 5 if it's last digit is 0 or 5.
A number is divisible by 6 if it's divisible by both 2 and 3.
A number is divisible by 7 if subtracting the last digit twice from the other digits is a multiple of 7.
A number is divisible by 8 if it's a multiple of 8.
A number is divisible by 9 if it's a multiple of 9.
A number is divisible by 10 if it's last digit is 0.
Remainder and Modulation
You've probably already observed us using modulus to find even and odd numbers and divisibility. The following snippet iterates how to get the remainder from a number and it's divisor.
Prime and Composite Numbers
Prime numbers is a natural number (not a decimal) that has no divisors other then one and itself. Composite numbers on the otherhand represent numbers that have divisors other then one and itself. The following code snippet shows how to identify a prime or composite number.
Mersenne Prime Numbers
Mersenne Prime Numbers are when 2^n - 1 is a prime number then n is also a prime number. We can compute whether a number is a Mersenne Prime Number with the following code snippet.
Prime Factors are a fundamental theroem in arithmetic. Essentially any number greater than 1 is either a prime number or can be written as a product of prime numbers. The following snippet of code figures out both the prime factors and the multiples required to make the product value.
Perfect Squares and Cubes are pretty straight forward. They are literally just exponential formulas. 2^2 = 2 * 2 which is a perfect square. 3 ^ 3 = 3 * 3 * 3 which is a perfect cube. This can be notated by any number that can be multipled accordingly. Surprisingly, Perfect Squares and Prime Factors are directly linked in that they can be determined through prime factorization.
Factors are similar to Prime Factors, except we find any resultant multiple with composite and prime numbers. For example the factors of 12 are: 1,2,3,4,6,12 since all those numbers can multiply one or the other to create 12.
The Euclidean Algorithm is a great way to find the greatest common divisor without doing factorization of each respective number. There are two versions of Euclidean's algorithm. The normal and extended version.
Factorials are a bit different then factors in that we multiply it by each smaller number then it's respective value. The concept is fairly straight forward though.