Divisibility
Divisibility
We say that a nonzero b divides a if a=qb for some m, where a,b and q are
integers.That is b, divides a if there is no remainder on division.The notation b∣a is
commonly used to meanb divides a.Also, if b|a, we say that b is a divisor of a. If b does not divide a we denote it by b∤a.
For example, 6∣36 but 7∤36. Note that b∣0 for any non-zero integer b and 1∣a for any integer a. When we write b∣a, it is tacitly assumed that b is a non-zero integer.
We can easily deduce the following properties form the definition of divisibility itself
Let a,b,c,d be any non-zero integers.
1.if a|1 , then a=±1
2. If a|b and b|c then a|c.
Proof: (1) Suppose b=na and c=mb, where n;m∈Z. Then c=m(na)=(mn)a and so a|c.
3. If a|b and c|d then ac|bd.
Proof: (2) Suppose b=na and d=mc where n;m∈Z. Then bd=(na)(mc)=(mn)(ac), i.e.,
ac|bd.
4.If a|x and a|y then a|cx+dy for any integers c;d.
Proof: x=an;y=am
⇒cx+dy=c(an)+d(am)
⇒a(cn+dm)⇒a|cx+dy
Example: 7|14 and 7|63, Then 7|(2∗14+3∗63)
7|7(2∗7+3∗9)
5.If d|a and a≠0 then |d|≤|a|
6.if a|b and b|a if and only if a=±b.
a|b⇒|a|≤|b|
b|a⇒|b|≤|a|
⇒|a|=|b|
⇒a=±b
Quotient and Remainder
If a and n are integers with n>0 , then there is unique pair of integers q and r such that
a=qn+r0≤r<n
If a=9 and n=4, then we have 9=2∗4+1 with 0≤1<4, so q=2 and r=1.If a=−9 and n=4 then q=−3 and r=3
We call q the quotient and r the remainder.By dividing by n, so that
an=q+rnand0≤rn<1
We see that q is the integer part ⌊a/n⌋ of a/n, the greatest integer i≤a/n. This makes it easy to calculate q, and then to find r=a−qn.The remainder is often referred to as a residue.
Python code to find all positive divisors of a number
def find_divisors(n):
# Initialize an empty list to store divisors
divisors = []
# Iterate from 1 to the square root of n
for i in range(1, int(n**0.5) + 1):
# If i is a divisor of n
if n % i == 0:
divisors.append(i)
# Add the complement divisor if it's different
if i != n // i:
divisors.append(n // i)
# Sort the list of divisors
divisors.sort()
return divisors
# Example usage
number = 24
print(f"All positive divisors of {number} are: {find_divisors(number)}")
Output
All positive divisors of 24 are: [1, 2, 3, 4, 6, 8, 12, 24]
Quotient and remainder
print("q=",9//4)
print("r=",9%4)
print("q=",-9//4)
print("r=",-9%4)
Output
q= 2
r= 1
q= -3
r= 3
Comments
Post a Comment