We start our introduction to number theory with definitions, properties, and relationships of several categories of numbers.
Triangular numbers are those that can be written as the sum of a consecutive series of (whole) numbers beginning with 1. Thus 6 is triangular because it is the sum of the first three numbers: 6 = 1 + 2 + 3. The first few triangular numbers are 1, 3, 6, 10, 15, 21, 28, 36, 45, and 55. We denote the nth triangular number by tn. Thus t5 = 1 + 2 + 3 + 4 + 5 = 15. More generally,
The nth triangular number is given by the formula:
It should be noted that
The sum of any two consecutive triangular numbers is a square. For example, t4 + t3 = 10 + 6 = 16 = 42 and t5 + t4 = 15 + 10 = 25 = 52. This is expressed by the formula
The sum of the reciprocals of all the triangular numbers is 2. Formally,
A positive integer of the form n(n + 1) is called oblong. The nth oblong number is the sum of the first n even numbers. To see this, observe that the nth even number is 2n. Then we have , the nth oblong number. What about the sum of the first n odd numbers? The nth odd number is 2n − 1. So , in which −1 appears n times. We then get . So the sum of the first n odd numbers is n2.
The great French mathematician LaGrange (1736–1813) showed in the late eighteenth century that every positive number can be written as a sum of four or fewer squares. Thus, for example, 30 = 25 + 4 + 1.
Number theorists are fond of numbers, such as 40, which are the sum of only two squares (e.g., 40 = 36 + 4).
The Pythagoreans computed the sum of the first n powers of 2. Let
Now subtract Equation (a) from Equation (b), and we get S = 2n − 1. We have, then, the following formula:
With a minor change in the proof of (1.6), we obtain an analogous formula for the sum of the first n powers of any base. Let . Then . Subtract the first equation from the second, and we get (a − 1)S = an − 1. Upon division by a − 1, we obtain the following formula:
The Pythagoreans classified all numbers as deficient, abundant, or perfect. Given a number, find all of its proper factors, that is, all numbers that go into it (with the exclusion of the given number). The proper factors of 30, for example, are 1, 2, 3, 5, 6, 10, and 15.
If the sum of the proper factors of n is less than n, we call n deficient. If the sum exceeds n, it is called abundant. If the sum equals n, we call it perfect. For example, 8 is deficient since 1 + 2 + 4 < 8, 18 is abundant since 1 + 2 + 3 + 6 + 9 > 18, and 28 is perfect since 1 + 2 + 4 + 7 + 14 = 28. The smallest perfect number is 6. The first few perfect numbers are 6, 28, 496, and 8128. It is not known today whether there are infinitely many perfect numbers. Moreover, all known perfect numbers are even. No one knows if there are any odd perfect numbers! Incidentally, the smallest abundant odd number is 945, while the smallest abundant even number is 12.
The Pythagoreans found an amazing method for finding perfect numbers. They observed, using (1.6), that sums of the form are prime for certain values of n and are composite for others. (A number is prime if its only factors are 1 and itself. 7, 19, and 31 are examples of primes. A composite number has proper factors other than 1. Thus 20 is composite.) The following sums, for example, are prime:
In each of these equations, multiply the greatest number on the left by the number on the right, yielding 2 × 3 = 6, 4 × 7 = 28, 16 × 31 = 496, and 64 × 127 = 8128. These products, 6, 28, 496, and 8128 are perfect. Whenever the sum of the first n powers of 2 is prime, this procedure yields a perfect number! Using (1.6), the sum of the first n powers of 2 is 2n − 1, so the perfect number is of the form 2n−1(2n − 1). The prime sum, 2n − 1, is then called a Mersenne prime, in honor of the eighteenth century French mathematician. It was shown in the eighteenth century by the great Swiss mathematician Leonhard Euler (1707–1783) that all even perfect numbers are of the form 2n−1(2n − 1).
A conjecture is that no odd number (odd number >1) is perfect. One of the exercises and one of our programs tests this conjecture on the first 1000 odd numbers.
The Pythagoreans believed that if two friends wore amulets, one with 220 and the other with 284, they would fortify their friendship. This is because the sum of the proper factors of either one of these numbers equals the other number, that is,
We call a pair of numbers with this property, amicable numbers. 1184 and 1210 comprise the next pair of amicable numbers, since
An asterisk (*) indicates that the exercise can be developed into a research project.
Triangular Numbers
<html>
<head>
<title>Triangular Numbers</title>
<script>
var n = 1000000;
var start = new Date();
start = start.getTime();
function init(){
var sum = 0;
for(i=1;i<=n;i++){
sum+=i;
}
now = new Date();
now = now.getTime();
elapsed = (now - start);
document.write("The "+n+
"th triangular number is "+sum+".<br/>");
document.write("Elapsed time was "+elapsed+"milliseconds.");
}
init();
</script>
</head>
<body>
</body>
</html>
Proper Factors
<!DOCTYPE HTML>
<html>
<head>
<title>Proper factors</title>
<script>
var n = 30;
var count = 0;
function countUpFactors(n){
document.write("Proper factors of "+n+" are:
<br/>");
for (var i=1;i<n;i++){
if ((n%i)==0){
count++;
document.write(i+"<br/>");
}
}
document.write("The number of proper factors
of "+n+" is "+count+".");
}
countUpFactors(n);
</script>
</head>
<body>
</body>
</html>
Classifying Number as Deficient, Perfect, or Abundant
<!DOCTYPE HTML>
<html>
<head>
<title>Perfect or </title>
<script>
function addUpFactors(n){
document.write("Proper factors of "+n+" are:
<br/>");
var sum = 0;
for (var i=1;i<n;i++){
if ((n%i)==0){
document.write(i+"<br/>");
sum += i;
}
}
document.write("The sum of the proper factors
of "+n+" is "+sum+", so "+n+" is ");
if (sum<n) {
document.write("deficient.");
}
else if (sum==n) {
document.write("perfect.");
}
else {
document.write("abundant.");
}
document.write("<br/>");
}
addUpFactors(6);
addUpFactors(8);
addUpFactors(18);
addUpFactors(28);
addUpFactors(945);
addUpFactors(8128);
</script>
</head>
<body>
</body>
</html>
Checking the Conjecture on No Perfect Odd Number (up to 1000)
<!DOCTYPE HTML>
<html>
<head>
<title>Sort Odd numbers </title>
<script>
function classify(n){
var sum = 0;
for (var i=1;i<n;i++){
if ((n%i)==0){
//document.write(i+"<br/>");
sum += i;
}
}
if (sum<n) {
return -1;
}
else if (sum==n) {
return 0;
}
else {
return 1;
}
document.write("<br/>");
}
function sortOdds(limit) {
var perfect = 0;
var deficient = 0;
var abundant = 0;
for (var j=1;j<=limit;j++) {
var n=2*j+1;
c = classify(n);
if (c==-1){
deficient++;
}
else if (c==1) {
abundant++;
}
else {
perfect++;
}
}
document.write("First "+limit+" odd numbers:
<br/>");
document.write ("deficient: "+deficient+
"<br/>");
document.write("abundant: "+abundant+
"<br/>");
document.write("perfect: "+perfect+"<br/>");
}
sortOdds(1000);
</script>
</head>
<body>
</body>
</html>