JustToThePoint English Website Version
JustToThePoint en español
JustToThePoint in Thai

Elementary Maths

Divisors

A divisor of a given number “a” is a number by which “a” is divisible without a remainder.

How do we find all divisors of a given number. Let’s use Maxima, WolframAlpha and Python. Maxima is a free computer algebra system that can be installed in Windows, macOS, and Linux. It is very powerful, fast, and very easy to use, ideal for students, teachers, and researchers alike.

Remember that multiples of 2 are all even and always end in the digits of 2, 4, 6, 8 or 0. Furthermore, the sum of all digits of a multiple of 3 or 9 is also a multiple of 3 or 9. The multiples of 5 end in 0 or in 5. The multiples of 6 end in 0, 2, 4, 6, 8, and the sum of all its digits is a multiple of 3, too. Multiples of 11 can be identified if the alternating sum of their digits is a multiple of 11 (7293: 7 -2 +9 -3 = 11).

You just type in an expression and press Shift and Enter, e.g. the query divisor(24); gives back the divisor of 24.You will get 1, 2, 3, 4, 6, 8, 12, 24.

You can also perform basic calculations, such as 3*7 (21), 6**2 (62=36), sqrt(16); (=4). Calculating divisors with Maxima

Calculating divisors with Maxima

Let’s do it with Python.

Python is an interpreted high-level general-purpose programming language. It is robust, popular, easy to learn, and it is available on a wide variety of platforms (Linux, Windows, and macOS) and comes preinstalled on most Linux distributions.

user@pc:~$ python
Python 3.8.6 (default, May 27 2021, 13:28:02) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sympy import divisors # We need to import the SymPy library
>>> print(divisors(24)) # Return all divisors of n 
[1, 2, 3, 4, 6, 8, 12, 24]
>>> print(divisors(124)) 
[1, 2, 4, 31, 62, 124]

Primes

A prime number is one with exactly two positive divisors or factors, itself and one.

Maxima’s command primep() is useful for testing whether or not an integer is prime or not, e.g. 7 (primep(7); return true) is a prime number, but 36 is not (primep(36); return false). The command next_prime(n) returns the next prime number greater than or equal to n

WolframAlpha uses natural language processing to understand queries, such as is 7 a prime number?, primes between 1 and 100, divisors of 48, etc. Calculating prime numbers

Calculating prime numbers

user@pc:~$ python 
Python 3.8.6 (default, May 27 2021, 13:28:02) [GCC 10.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. 
>>> from sympy import primerange, prime, isprime # We need to import the primerange, prime, and isprime functions from the SymPy library 
>>> print(list(primerange(0, 36))) # Return all prime numbers in the range [0, 36): 
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]

1 is not a prime number. A prime number is a positive integer that has exactly two positive divisors. However, 1 only has one positive divisor (1 itself), so it is not prime.

>>> prime(5) # prime(n) return the nth prime, with the primes indexed as prime(1) = 2, prime(2) = 3, etc., prime(5) = 
11 
>>> isprime(17) # isprime tests if n is prime 
True
>>> isprime(32)
False

Prime factorization

Prime factorization is the process of discovery or finding which prime numbers (prime factors) you need to multiply together to get a certain number.

Observe that factor(180); factor(420); or factor(54); give back the prime factorization of 180, 420, and 54 respectively in Maxima and WolframAlpha, the only difference is the use of a semicolon (;) in Maxima. Prime factorization

Prime factorization

user@pc:~$ python 
Python 3.8.6 (default, May 27 2021, 13:28:02) [GCC 10.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. 
>>> from sympy import factorint, pprint 
>>> pprint(factorint(420, visual=True))

22 ⋅31 ⋅51 ⋅71

>>> pprint(factorint(180, visual=True))

22 ⋅32 ⋅51

Greatest common divisor (gcd) and least common multiple (lcm)

The greatest common divisor (gcd) of two numbers (420, 54) is the largest product of primes that the two numbers share or the largest number that divides both of them without remainder. The least common multiple (lcm) of two numbers is the smallest number that is a multiple or is evenly divisible by both of them.

They both can be determined using prime factorization, 420 = 22 * 3 * 5 * 7, and 54 = 2 * 33. The lcm is the product of multiplying the highest power of each prime number (all factors found in either of the original number), lcm(420, 54) = 22 * 33 * 5 * 7 = 3780. The gcd is the product of multiplying the lowest power of common factors, gcd(420, 54) = 2 * 3 = 6.

The least common multiple of two numbers is the product of the two numbers divided by their greatest common divisor: 3780 = (420 * 54) / 6. Calculating gcd and lcm with Maxima and WolframAlpha

Calculating gcd and lcm with Maxima and WolframAlpha

user@pc:~$ python
Python 3.8.6 (default, May 27 2021, 13:28:02) [GCC 10.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. 
>>> import math 
>>> math.gcd(420, 54)
6 
>>> 420*54/6 # lcm(420, 54) = 420*54/math.gcd(420, 54)
3780

Powers and roots

The power of a number is the amount of times that a number is to be multiplied by itself. For example, 7 to the power of two is 49, 72 = 7 x 7 = 49; 4 to the power of three is 64, 43 = 4 x 4 x 4 = 64. The square root of a number is a number that, when multiplied by itself, equals the original number. It is the inverse operation of squaring than number. For example, the square root of √49 is 7, the square root of √64 is 8, etc.

If you want to raise a number n to a power p in Maxima, simply type n^p, such as 4^3; (= 64), 7^2; (= 49) or 2^4; (= 16). If you want to calculate the square root of a number (64) in Maxima, then your query would look like sqrt(49); You can use Qalculate!, Wolfram Alpha, and Google using the same syntax but without the semicolon “;”.

The Google Calculator is a pretty simple calculator, but it’s nicely designed, minimalistic, and quite easy to use.

Powers and roots

Powers and roots

inrt(x, n) returns the n’th root of x, e.g. inrt(64, 3); = 4 (4^3; = 64),

l: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; 
powerl: map (lambda ([a], a^3), l); 
= [1, 8, 27, 64, 125, 216, 343, 512, 729, 1000, 1331, 1728]. 
map (lambda ([a], inrt(a, 3)), powerl);
= [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
user@pc:~$ python
Python 3.8.6 (default, May 27 2021, 13:28:02) [GCC 10.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. 
>>> import math 
>>> math.sqrt(49) # sqrt() function returns the square root of any number. 
7 
>>> pow(4, 3) # pow() returns the power of a number. 
64 
>>> 64**(1/3) # It calculates the cube root of 64
3.9999999999999996

Roman, Greek, Mayan, and Babylonian numeric systems

Roman numerals is the numeric system used in ancient Rome. They are formed by combining symbols (I, V, X, L, C, D, and M) together and adding their values (I is 1, V is 5, X is 10, and so on). For instance, the numbers 1 to 15 are expressed in Roman numerals as follows: I, II, III, IV, V, VI, VII, VIII, IX, X, XI, XII, XIII, XIV, XV.

However, it is a little more complicated than that. When a symbol of lesser value (I = 1) comes before a symbol of greater value (V = 5), we need to subtract the lesser value from the greater value (5 - 1), and add the result to the total, so XIV is 10 + (5 - 1) = 10 + 4 = 14.

Wolfram Alpha converts decimal numbers to Roman (123 to Roman numerals), Greek (234 to Greek numerals), Mayan (573 to Mayan), and Babylonian numerals (457 to Babylonian). It can also convert from one numeral system to another (XVI to Mayan), do arithmetic operations with Roman numerals (XLVI + MMIV), etc.

Qalculate! can handle conversions between Roman numerals and decimal numbers. The result of calculations is displayed in the open area below the expression entry: the result display. Select Mode, Number Base, Roman Numerals to display the result using roman numerals. Besides, it can convert Roman numerals to decimal numbers by navigating through Functions, Miscellaneous, Roman Number, and typing the Roman numerals as CXXV (roman(CXXV) = 125).

Roman numeral

Roman numeral

user@pc:~$ python 
Python 3.8.6 (default, May 27 2021, 13:28:02) [GCC 10.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. 
>>> import roman # Small helper library to convert arabic to roman numerals. 
>>> print(roman.toRoman(124)) # It converts Arabic numbers to Roman Numerals. 
CXXIV 
>>> print(roman.toRoman(87)) # It converts Arabic numbers to Roman Numerals. 
LXXXVII 
>>> print(roman.fromRoman("MML")) # It converts Roman Numerals to Arabic numbers. 
2050 
>>> print(roman.fromRoman("XCVIII")) # It converts Roman Numerals to Arabic numbers. 
98

Other number systems: binary, octal, and hexadecimal

A number system is a writing system for expressing or representing numbers. The most common one used today is called the decimal system. It has ten symbols (0-9) and it has been so widely adopted throughout the world that you may not know that other number systems do indeed exist.

The binary system has a base of two and uses only two symbols: 0 and 1. Therefore, when you count in binary, it goes like this: 0 (0), 1(1), 10(2), 11(3), 100(4), 101(5), 110(6), 111(7)…, and thus each place value is a power of 2 instead of a power of 10. 10102 = 1*23 + 1*21 = 10. Computers see everything in terms of binary.

You may want to check our Python class for representing and operating on natural numbers. More specifically, we make use of the Finger Binary ASCII art generator for Python. Finger binary is a system for counting and displaying binary numbers on the fingers and thumbs of one or more hands. It is possible to count from 0 to 1023(210−1).

The octal numeral system is the base-8 number system and uses eight symbols starting from 0 to 7. This system is also a positional number system, which means that the value of each digit depends on the position of the digit in the number and it is called the place value of that digit. In base 8, each digit represents a power of 8. For example: 2758 = 2*82 + 7*81+ 5*80 = 189. The place value of digit 7 is 7*81 = 56.

The hexadecimal system has a base of sixteen and it uses sixteen different symbols: 0, 1, 2, … 9, A(10), B(11), C(12), D(13), E(14), F(15). Under this system, each symbol’s place value is worth 16 times more than the same symbol in the place value to its right. For instance: 1F216 = 1 * 162 + 15*161 + 2 * 160 = 498

Qalculate! can handle conversions between different number systems. Select Mode, Number Base, Binary, Octal, Decimal or Hexadecimal to display the result in binary, octal, decimal or hexadecimal. It allows us to write numbers in binary, octal or hexadecimal form by preceding them with the appropriate prefix: 0b, 0o (zero “0” and letter “o”), or 0x: 0b1101102 (= 54), 0o168 (= 14), 0x2D16 (= 45).

Wolfram Alpha and Google can convert numbers between different bases. To convert a number to binary, octal, hexadecimal, or decimal, type the number followed by the words to binary, to octal, to hex, or to decimal. Besides, Wolfram Alpha can perform computations with numbers on different bases.

Numeric Systems

Numeric Systems

user@pc:~$ python 
Python 3.8.6 (default, May 27 2021, 13:28:02) [GCC 10.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. 
>>> print(bin(79)) # It converts from decimal to binary. The prefix 0b indicates that the value is in binary. 
0b1001111 
>>> print(oct(79)) # It converts from decimal to octal. The prefix 0o indicates that the value is in octal. 
0o117 
>>> print(hex(79)) # It converts from decimal to hexadecimal. The prefix 0x indicates that the value is in hexadecimal. 
0x4f 
>>> print(int("0b1001111", 2)) # It converts from binary to decimal. 
79 
>>> print(int("0o117", 8)) # It converts from octal to decimal. 
79 
>>> print(int("0x4f", 16)) # It converts from hexadecimal to decimal. 
79

Integers

Integers are whole numbers (1, 2, 3, 4,…), negative of whole numbers (-1, -2, -3, -4,…), and the number zero(0). Negative whole numbers are used for expressing temperatures below freezing (0ºC), for measuring altitude below sea level, and when someone withdraws more than the current balance. Qalculate!, Maxima, Google, and WolframAlpha can perform computations with integers.

“If a person is engaged in trade, his capital will be increased by his gains, and diminished by his losses. Increase in temperature is measured by the number of degrees the mercury rises in a thermometer, and decrease in temperature by the number of degrees the mercury falls. In considering any quantity whatever, a quantity that increases the quantity considered is called a positive quantity; and a quantity that decreases the quantity considered is called a negative quantity,” The First Steps in Algebra, G. A. Wentworth.

The absolute value of a number is its distance from zero on the number line: |-4| = 4, |7| = 7. The absolute value of a positive number is just the number itself, abs(9) = 9. The absolute value of zero is zero, abs(0) = 0; and the absolute value of a negative number is its opposite, abs(-7) = 7.

The opposite of a number is the number that is situated at the same distance from 0 but in the opposite direction on the number line: -(-7)=7.

Operations with integers are a little tricky. Here is what we need to do when we add a negative and a positive number (-8 + 7). Use the sign of the larger number (-1) and subtract the smaller absolute value from the greater absolute value (8 - 7 = 1): -1.

You also need to remember: (R1) The product of a positive integer and a negative integer is always a negative integer: 4 * -3 = 12, -5 * 3 = 15. (R2) The product of two negative integers (-3 * -3 = 9, -4 * -5 = 20) or two positive integers (2 * 4 = 8, 4 * 7 = 28) is always a positive integer. The same rules apply to division: R1 (8 : -4 = -2, -4 : 2 = -2), R2 (8 : 4 = 2, -9 : -3 = 3).

You can see the representation of an integer on the Number Line with WolframAlpha. Just type a number. Qalculate!, Maxima, Google, and WolframAlpha can perform computations with integers

Qalculate!, Maxima, Google, and WolframAlpha can perform computations with integers

user@pc:~$ python
Python 3.8.6 (default, May 27 2021, 13:28:02) [GCC 10.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. 
>>> 4-5 
-1 
>>> -5*(-4) 
20 
>>> (-8)/(-4) 
2.0 
>>> (-4*7)-(-3*(-2)) 
-34 
>>> abs(-8) # abs() calculates the absolute value of the number passed as an argument 
8

You may want to check our Python class for representing and operating on natural numbers, Magic, happy, automorphic, narcissistic, handsome… numbers, and Abacus, Ascii Art, and Set of numbers.

Bitcoin donation

JustToThePoint Copyright © 2011 - 2022 PhD. Máximo Núñez Alarcón, Anawim. ALL RIGHTS RESERVED. Bilingual e-books, articles, and videos to help your child and your entire family succeed, develop a healthy lifestyle, and have a lot of fun.

This website uses cookies to improve your navigation experience.
By continuing, you are consenting to our use of cookies, in accordance with our Cookies Policy and Website Terms and Conditions of use.