# GAP 编程>Functions

## Divisors of consecutive integers

We now examine a problem which involves elementary number theory.

Are there infinitely many pairs of consecutive integers with the same number of divisors?

Is there an infinite number of pairs of consecutive integers that each have 4 divisors?

We have no hope of solving the problem but let us investigate it.

First note that DivisorsInt(n) returns a list of divisors of n.

DivisorsInt(1512);

[ 1, 2, 3, 4, 6, 7, 8, 9, 12, 14, 18, 21, 24, 27, 28, 36, 42, 54, 56, 63, 72, 84, 108, 126, 168, 189, 216, 252, 378, 504, 756, 1512 ]

It is easy to find the number of divisors of n.

Length(DivisorsInt(1512));

32

For ease of typing let us define f(n) to be the number of divisors of n.

f:= n -> Length(DivisorsInt(n));

function( n ) ... end

# GAP 编程>Functions

## Divisors of consecutive integers

Let us look for pairs of consecutive integers with the same number of divisors.

for i in [1..200] do
if f(i) = f(i+1) then
Print("pair ", i," ", i+1, " has ",f(i), " divisors ", "\n");
fi;
od;

pair 2 3 has 2 divisorspair 14 15 has 4 divisorspair 21 22 has 4 divisorspair 26 27 has 4 divisorspair 33 34 has 4 divisorspair 34 35 has 4 divisorspair 38 39 has 4 divisorspair 44 45 has 6 divisorspair 57 58 has 4 divisorspair 75 76 has 6 divisorspair 85 86 has 4 divisorspair 86 87 has 4 divisorspair 93 94 has 4 divisorspair 94 95 has 4 divisorspair 98 99 has 6 divisors

pair 104 105 has 8 divisorspair 116 117 has 6 divisorspair 118 119 has 4 divisorspair 122 123 has 4 divisorspair 133 134 has 4 divisorspair 135 136 has 8 divisorspair 141 142 has 4 divisorspair 142 143 has 4 divisorspair 145 146 has 4 divisorspair 147 148 has 6 divisorspair 158 159 has 4 divisorspair 171 172 has 6 divisorspair 177 178 has 4 divisorspair 189 190 has 8 divisors


# GAP 编程>Functions

## Divisors of consecutive integers

We can easily move to finding three consecutive integers with the same number of divisors.

for i in [1..200] do
if f(i) = f(i+1) and f(i+1)=f(i+2)	then
Print("triple ", i," ", i+1, " ", i+2," has ", f(i)," divisors ", "\n");
fi;
od;

triple 33 34 35 has 4 divisorstriple 85 86 87 has 4 divisorstriple 93 94 95 has 4 divisorstriple 141 142 143 has 4 divisors

Then we can look for even longer runs. This code uses a different kind of loop.

i:=1;;
over:=false;;
while not over do
if f(i) = f(i+1) and f(i+1)=f(i+2) and f(i+2)=f(i+3) and f(i+3)=f(i+4) and f(i+4)=f(i+5) and f(i+5)=f(i+6) then
Print("Sequence of length 7 starting ",i," has ",f(i)," divisors \n");
over:=true;
fi;
i:=i+1;
od;

Sequence of length 7 starting 171893 has 8 divisors

# GAP 编程>Functions

## Divisors of consecutive integers

As an exercise you may care to turn the above into a function with a parameter n which returns sequences of length n of integers with the same number of divisors.

Can one find such runs of arbitrary length? GAP can help, but won't tell you the answer!

JOC/EFR January 2003

# 改进 GAP

How to improve GAP(编写自己的宏包, 编写GUI)

# Data Libraries

• 小群(SmallGroups)
• Basic Groups
• 典型群(Classical Groups)
• 完美群(Perfect Groups)
• 可迁置换群(Transitive Permutation Groups)
• 本原置换群(Primitive Permutation Groups)
• 不可约的可解矩阵群(Irreducible Solvable Matrix Groups)
• IRREDSOL

# References

http://www-circa.mcs.st-and.ac.uk/gapintro.php

# End

Thanks very much!

Welcome to visit my site: www.atzjg.net