by
Louis Marmet
Updated June 13th, 2007
The first few square-free numbers give the sequence:
1, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30,
31, 33, 34, 35, 37, 38, 39, 41, 42, 43, 46, 47, 51, 53, 55, 57, 58, 59,
61, 62, 65, 66, 67, 69, 70, 71, 73, 74, 77, 78, 79, 82, 83, 85, 86, 87,
89, 91, 93, 94, 95, 97, etc. (Sloane's A005117)
More details on square-free numbers can be found at http://mathworld.wolfram.com/Squarefree.html.
(If a square-free number is used as the argument of the Möbius
function, a non-zero value (+1 or -1) is obtained.)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
For any L, it can be shown that there exist infinitely many
gaps
of length greater than L in the sequence of square-free
numbers.
Longer lists of square-free gaps and recent results are available
here.
These gaps are series of consecutive squareful
numbers (Sloane's A013929).
Note that the term "squarefull" sometimes denotes a positive
integer
n such that if p is a prime dividing n, then
p2
divides n. (See the preprint of Michael Filaseta at http://www.math.sc.edu/~filaseta/paperindex.html,
The
distribution of squarefull numbers in short intervals, with O.
Trifonov,
Acta
Arith., 67 (1994), 323-333.)
Qgap(L) is listed in the following table for L
up to 17. The third column gives the prime factors that are
repeated
for each number in the gap. The values of Qgap(L < 10
|
|
|
|
Gap reported by |
|
1
|
4
|
|
E. Friedman |
|
2
|
8
|
|
E. Friedman |
|
3
|
48
|
|
E. Friedman |
|
4
|
242
|
|
E. Friedman |
|
5
|
844
|
|
E. Friedman |
|
6
|
22 020
|
|
E. Friedman |
|
7
|
217 070
|
|
E. Friedman |
|
8
|
1 092 747
|
|
E. Friedman |
|
9
|
8 870 024
|
|
P. De Geest |
|
10
|
262 315 467
|
|
D. Bernier |
|
11
|
221 167 422
|
|
P. De Geest |
|
12
|
47 255 689 915
|
|
L. Marmet |
|
13
|
82 462 576 220
|
|
L. Marmet |
|
14
|
1 043 460 553 364
|
|
L. Marmet |
|
15
|
|
|
L. Marmet |
|
16
|
3 215 226 335 143 218
|
|
|
|
17
|
|
|
E. Wong |
|
18
|
|
|
|
|
|
|
| Qgap(16) |
46 717 595
829 767
167 *
|
(Feb. 17th, 2000) |
|
Qgap(17)
|
23 742 453
640 900
972 +
|
(Feb. 21st, 2000) |
|
Qgap(18)
|
125 781 000 834 058 568
|
(June 26th, 2000) |
|
Qgap(19)
|
31 310 794 237 768 728 712
|
(July 18th, 2000) |
|
Qgap(20)
|
148 372 453 443 663 297 638 331
|
(July 10th, 2000) |
|
Qgap(21)
|
321 362 101 382 225 854 472
|
(Feb. 17th, 2000) |
|
Qgap(22)
|
213 922 449 434 979 698 424 416
|
(Aug. 4th, 2000) |
|
Qgap(23)
|
687 445 369 966 391 012 821 156 868
|
(July 18th, 2000) |
| Qgap(24) |
28 548 715 276 566 524 078 226 797
585 011
|
(Sept. 4th, 2000) |
* The value of Qgap(16) was found to be
+ The value of Qgap(17) was
confirmed to be 23 742 453 640 900 972 (E. Wong,
A faster algorithm is used by "Mathematica" to determine if a number is square-free. The method is quite interesting (see: http://documents.wolfram.com/v5/Add-onsLinks/StandardPackages/NumberTheory/NumberTheoryFunctions.html )
However, to determine which of many consecutive numbers are square-free, an algorithm based on to the sieve of Eratosthenes is much faster. The sieve of Eratosthenes is explained on the web site at http://mathworld.wolfram.com/SieveofEratosthenes.html. It uses a list of numbers from which each composite number is removed. Once the process is finished, only the prime numbers are in the list.
To find the square-free numbers using a sieve, a
similar
technique is used but the algorithm eliminates numbers that are not
square-free.
Starting with a list of integers, first cross out the multiples of 4:
| 1 | 2 | 3 | X | 5 | 6 | 7 | X | 9 | 10 | 11 | X | 13 | 14 | 15 | X | 17 | 18 | 19 | X | 21 | 22 | 23 | X | 25 | 26 | ... |
then the multiples of 9, 25, etc., up to the last number in the
list:
| 1 | 2 | 3 | X | 5 | 6 | 7 | X | X | 10 | 11 | X | 13 | 14 | 15 | X | 17 | X | 19 | X | 21 | 22 | 23 | X | X | 26 | ... |
The remaining numbers are square-free numbers; the gaps are indicated by the series of consecutive "X".
To implement this algorithm on a computer, it is not necessary to keep the entire list of integers in memory. An improvement of the algorithm uses instead two shorter arrays to calculate the next non-square-free number after N:
To find the square-free gaps, one finds sequences of
non-square-free
numbers. The following example shows the arrays used to find gaps
starting from
(We use the notation used in the programming language C, where the
index of an array starts at 0.)
|
Index
|
i
|
0
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
...
|
|
|
Prime squared
|
p2[i]
|
4
|
9
|
25
|
49
|
121
|
169
|
289
|
361
|
529
|
...
|
|
|
Next non-square-free
|
nsqf[i]
|
24
|
27
|
25
|
49
|
121
|
169
|
289
|
361
|
529
|
...
|
Using this table, it is easy to find the next
non-square-free
number: it is the smallest number in the array nsqf, that is,
24.
We set
|
Index
|
i
|
0
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
...
|
|
|
Prime squared
|
p2[i]
|
4
|
9
|
25
|
49
|
121
|
169
|
289
|
361
|
529
|
...
|
|
|
Next non-square-free
|
nsqf[i]
|
28
|
27
|
25
|
49
|
121
|
169
|
289
|
361
|
529
|
...
|
Again, the next non-square-free number is the smallest
nsqf[i].
By repeating this procedure, N takes the values of all the
non-square-free
numbers.
It is advantageous to sort nsqf in increasing
order
at each step. This way, the smallest is always
nsqf[0].
We set
|
Index
|
i
|
0
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
...
|
|
|
Prime squared
|
p2[i]
|
9
|
4
|
49
|
25
|
121
|
169
|
289
|
361
|
529
|
...
|
|
|
Next non-square-free
|
nsqf[i]
|
27
|
28
|
49
|
50
|
121
|
169
|
289
|
361
|
529
|
...
|
The order of the array primesq has also been
changed
so that each number p2[i] always corresponds to its multiple nsqf[i].
Repeating the procedure will generate the non-square-free numbers
The sort is relatively efficient since after nsqf[0] is given its new value, nsqf[1], nsqf[2] and the following elements are still in increasing order. The new value has to be moved up the array until its proper place is found.
If gaps of a given length Lmin or
more
are searched, some nsqf[i] can be skipped. To show this,
we
first find the minimum number of squared-primes NP2min
required in a gap of length L:
|
Gap length L
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
9
|
10
|
11
|
12
|
13
|
14
|
15 | 16 |
17
|
... | |
|
|
1
|
2
|
3
|
4
|
4
|
5
|
6
|
7
|
7
|
|
|
|
|
10
|
11 | 12 |
12
|
... |
For example, if we chose
Continuing with the example given above, we now
specifically
search gaps with length
With
|
Index
|
i
|
0
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
...
|
|
|
Prime squared
|
p2[i]
|
4
|
9
|
49
|
25
|
121
|
169
|
289
|
361
|
529
|
...
|
|
|
Next non-square-free
|
nsqf[i]
|
44
|
45
|
49
|
50
|
121
|
169
|
289
|
361
|
529
|
...
|
Since
|
Index
|
i
|
0
|
1
|
2
|
3
|
4
|
5
|
6
|
7
|
8
|
...
|
|
|
Prime squared
|
p2[i]
|
4
|
169
|
9
|
25
|
49
|
121
|
289
|
361
|
529
|
...
|
|
|
Next non-square-free
|
nsqf[i]
|
164
|
169
|
171
|
175
|
196
|
242
|
289
|
361
|
529
|
...
|
This variation on Improvement II
turns out to be more efficient, especially when it is combined with Improvements
IV and V. The trick is to consider
the
smallest squared-primes separately from the large squared-primes.
Most of the time in the algorithm is spent on the process
of taking the smallest elements off of nsqf and sorting them
back
into the array. If one can reduce the number of non-square-free
numbers
which are tested, the speed of the algorithm will improve.
This is actually possible since the smallest
squared-primes
are not needed to calculate the sieve. If we have a gap of, say,
We therefore separate the small squared-primes from the
large ones, creating a base with k1 elements.
The
table for
|
Index
|
i
|
0
|
1
|
2
|
3
|
4
|
k
|
6
|
7
|
8
|
...
|
|
|
Prime squared
|
p2[i]
|
4
|
9
|
25
|
49
|
121
|
169
|
289
|
361
|
529
|
...
|
|
|
Next non-square-free
|
nsqf[i]
|
--
|
--
|
--
|
--
|
--
|
169
|
289
|
361
|
529
|
...
|
with the base shown in gray. From the table, one sees that one
must test for a gap having
|
Index
|
i
|
0
|
1
|
2
|
3
|
4
|
k
|
6
|
7
|
8
|
...
|
|
|
Prime squared
|
p2[i]
|
4
|
9
|
25
|
49
|
121
|
289
|
169
|
361
|
529
|
...
|
|
|
Next non-square-free
|
nsqf[i]
|
|
|
|
|
|
289
|
338
|
361
|
529
|
...
|
The sort is faster since it is only done on the large
squared-primes.
The process is then continued at
To test if there is a gap of
|
Index
|
i
|
0
|
1
|
2
|
3
|
4
|
k
|
6
|
7
|
8
|
...
|
|
|
Prime squared
|
p2[i]
|
4
|
9
|
25
|
49
|
121
|
289
|
169
|
361
|
529
|
...
|
|
|
Next non-square-free
|
nsqf[i]
|
|
|
|
|
|
289
|
338
|
361
|
529
|
...
|
|
|
|
mod[i] |
1
|
1
|
14
|
44
|
47
|
We see that p2[0] and p2[1]
divide
|
Index
|
i
|
0
|
1
|
2
|
3
|
4
|
k
|
6
|
7
|
8
|
...
|
|
|
Prime squared
|
p2[i]
|
4
|
9
|
25
|
49
|
121
|
169
|
361
|
529
|
289
|
...
|
|
|
Next non-square-free
|
nsqf[i]
|
|
|
|
|
|
338
|
361
|
529
|
578
|
...
|
|
|
|
mod[i] |
2
|
5
|
13
|
44
|
96
|
If we include p2[4] in the array of large
squared-primes,
(so there are only
|
Index
|
i
|
0
|
1
|
2
|
3
|
k
|
5
|
6
|
7
|
8
|
...
|
|
|
Prime squared
|
p2[i]
|
4
|
9
|
25
|
49
|
169
|
361
|
121
|
529
|
289
|
...
|
|
|
Next non-square-free
|
nsqf[i]
|
|
|
|
|
338
|
361
|
363
|
529
|
578
|
...
|
|
|
|
mod[i] |
|
|
|
|
Since
A chained list can be built with a set of numbers that
specify an order for the elements of an array. If we use a
chained
list represented by the array called next such that
|
Index
|
i
|
0
|
1
|
2
|
3
|
k
|
5
|
6
|
7
|
8
|
...
|
|
|
Chained list
|
next[i]
|
|
|
|
|
5
|
8
|
9
|
4
|
6
|
...
|
|
|
Prime squared
|
p2[i]
|
4
|
9
|
25
|
49
|
121
|
169
|
289
|
361
|
529
|
...
|
|
|
Next non-square-free
|
nsqf[i]
|
|
|
|
|
363
|
507
|
578
|
361
|
529
|
...
|
|
|
|
mod[i] |
|
|
|
|
We use an additional variable, "head", which points to
the smallest item in the array nsqf. For the table above,
we have
There is another advantage to this method: since the
array
p2
is sorted in increasing order, we know that if we have to sort item nsqf[
for (i=head-1; tempnsqf>=nsqf[i2=next[i]]; i=i2) { ... }
We continue the example with the above table.
Since
|
Index
|
i
|
0
|
1
|
2
|
3
|
k
|
5
|
6
|
7
|
8
|
...
|
|
|
Chained list
|
next[i]
|
|
|
|
|
5
|
8
|
7
|
9
|
6
|
...
|
|
|
Prime squared
|
p2[i]
|
4
|
9
|
25
|
49
|
121
|
169
|
289
|
361
|
529
|
...
|
|
|
Next non-square-free
|
nsqf[i]
|
|
|
|
|
363
|
507
|
578
|
722
|
529
|
...
|
|
|
|
mod[i] |
|
|
|
|
with head now equal to 4.
A factor three in speed was obtained when this algorithm was implemented in the program.
Instead of having k
|
Index
|
i
|
0
|
1
|
2
|
k3
|
4
|
5
|
6
|
7
|
8
|
...
|
|
|
Chained list
|
next[i]
|
|
|
|
|
3
|
8
|
7
|
9
|
6
|
...
|
|
|
Prime squared
|
p2[i]
|
4
|
9
|
25
|
49
|
121
|
169
|
289
|
361
|
529
|
...
|
|
|
Next non-square-free
|
nsqf[i]
|
|
|
|
|
363
|
507
|
578
|
722
|
529
|
...
|
|
|
|
mod[i] |
|
|
|
In this example, we look at the difference between
This improvement gives the program a 37% speed increase
with
The program becomes slower if four or more large squared-primes are considered (I tested this for L>13, N = 1014 to 1014 +109).
First, consider the case when p2[0]=4 which occurs with a probability of 1/4. Since nsqf[0] has been increased by 4, there is a probability of 4/9 that it will have to be moved above nsqf[j] (if p2[j]=9). There is an additional probability of 4/25 that nsqf[0] will have to be moved above nsqf[k] (if p2[k]=25), etc. We therefore get the average number of steps required to place the new nsqf[0] to its correct position:
where p(i) is the ith prime number (p(1)=2, p(2)=3, p(3)=5, etc.) and p2(i) = p(i)×p(i).
In the case when p2[0]=9 (which occurs with a probability of 1/9), one move is always necessary to bring nsqf[0] above nsqf[j] (if p2[j]=4). There is a probability of 9/25 that nsqf[0] will have to be moved above nsqf[k] (if p2[k]=25), etc. We therefore get:
In general, when p2[0]=p2(m), the average number of moves is:
The sum over all the S(m) gives the average number of moves required to place nsqf[0] to its correct position in the list:
This series converges, as determined with the convergence
test 0.224 given in Table of Integrals, Series, and Products
by Gradshteyn and Ryzhik (Academic Press, Inc.,
Contributed to find Qgap(16):
Contributed to find Qgap(17): E. Wong,
The search for Qgap(18) is an ongoing
team project. Contributions were made by
This project started from an idea that was initially suggested to me by David Bernier.
The Prime Puzzles and Problems Connection. Carlos Rivera. http://www.primepuzzles.net/problems/prob_028.htm (not updated since Nov. 1999)
B. de Weger and C.E. van de Woestijne, http://www.xs4all.nl/~deweger/publikaties.html
On the powerfree parts of consecutive integers,
Acta Arithmetica 90 [1999], 387 - 395.
Copyright © 1999 Louis
Marmet