Prime Factors Operation With Filter Condition

A filter condition restricts the numbers considered by the program to positive integers in a particular sequence, e.g., 10n + 2, which (for n >= 0) consists of the numbers 3, 12, 102, 1002, ...

There are nine possible types of filter condition (division must be exact):

 Filter type Examples a b n an integer and resulting number >= 1 a*n + b 3 1 1, 4, 7, ... a*n - b 7 12 2, 9, 16, ... a*n ± b 7 12 2, 5, 9, 12, 16, 19, ... a/n + b 1000 1 2, 3, 5, 6, 9, 11, 21, 26, ... a/n - b 105 1 2, 4, 6, 14, 20, ... a/n ± b 105 1 2, 4, 6, 8, 14, 16, 20, 22, ... an + b 2 1 2, 3, 5, 9, 17, ... an - b 3 2 3, 5, 11, 29, 83, ... an ± b 3 2 1, 3, 7, 5, 11, 25, 29, 79, 83, ...

Examples of results obtained with various filter conditions in effect are given below.

It looks like all colors of the form 12*N + 1 are black. But 385 = 12*32 + 1 = 5*7*11 is white. (All white colors have at least 3 prime factors.)

Numbers of the form 12*N + 11 are all either yellow or blue. But if the number is prime then it is always blue.

All Mersenne primes (i.e., primes of the form 2n-1) are green. There are only 7 Mersenne primes less than 600,000. As of 2019 there are only 50 known Mersenne primes, the larges of which has 23,249,425 digits.

Fermat primes are primes of the form 2(2n)+1. They can be found by this program by using the filter 2n+1. Other than 3, the are all red. It is conjectured that there are no other Fermat primes.