# Simple Arithmetic

In :
from xv.math.kids import Arithmetic as AM
from xv.util import listAttr

In :
help(AM.count)

Help on method count in module xv.math.kids._arithmetic:

count(*args) method of builtins.type instance


In :
AM.count(2, "tiger")

Out:

## 🐅🐅 2

In :
AM.count(5)

Out:

## 👧👧👧👧👧 5

In :
AM.count(1, 5)

Out:

## 👧👧👧👧👧 5

In :
AM.count(-5, 1)

Out:

## 👧 1

In :
AM.add(45,- 20)

Out:

## = 25

In :
AM.multiply(30, 29)

$\displaystyle 30 * 29$
Flip to keep smaller number (absolute values) first

$\displaystyle 29 * 30$
Expand numbers

$\displaystyle (20 + 9) * 30$
Distribute multiplier

$\displaystyle 20 * (30) + 9 * (30)$
Sort

$\displaystyle 600 + 270$
Answer

$\displaystyle 870$
In :
AM.lcm(4, 5, 4)

Calculating LCM of 4, 5, 4

Multiples of 4 = [ 4  8 12 16 20]

Multiples of 5 = [ 5 10 15 20]

Multiples of 4 = [ 4  8 12 16 20]

The lowest common multiple (LCM) of all numbers 20

Out:
20
In :
AM.addInMemory(36, 35)

Out:

## + 71

In :
AM.prime(28)

Finding 5 prime numbers >= 28

Is 28 a prime number?
Square root of 28 is less than 6.
The prime numbers smaller than 6 are:
[2, 3, 5]
So, we will check whether 28 is divisible by any of the above prime numbers
As 28 is divisible by 2, it is not a prime number.

Is 29 a prime number?
Square root of 29 is less than 6.
The prime numbers smaller than 6 are:
[2, 3, 5]
So, we will check whether 29 is divisible by any of the above prime numbers

29 is a prime number.
It is not divisible by prime numbers less than or equal to its square root 5.4:
[2, 3, 5]

Is 30 a prime number?
Square root of 30 is less than 6.
The prime numbers smaller than 6 are:
[2, 3, 5]
So, we will check whether 30 is divisible by any of the above prime numbers
As 30 is divisible by 2, it is not a prime number.

Is 31 a prime number?
Square root of 31 is less than 6.
The prime numbers smaller than 6 are:
[2, 3, 5]
So, we will check whether 31 is divisible by any of the above prime numbers

31 is a prime number.
It is not divisible by prime numbers less than or equal to its square root 5.6:
[2, 3, 5]
....

37 is a prime number.
It is not divisible by prime numbers less than or equal to its square root 6.1:
[2, 3, 5]
....

41 is a prime number.
It is not divisible by prime numbers less than or equal to its square root 6.4:
[2, 3, 5]
....

43 is a prime number.
It is not divisible by prime numbers less than or equal to its square root 6.6:
[2, 3, 5]
Finding 5 prime numbers >= 28

$\displaystyle [29, 31, 37, 41, 43]$
Out:
[29, 31, 37, 41, 43]
In [ ]: