Showing posts with label haskell. Show all posts
Showing posts with label haskell. Show all posts

Sunday, October 26, 2025

[blyqokgn] simultaneously define record type and data

we propose a Haskell syntax extension which may be useful when a record type has very few data values of that type, perhaps just one, e.g., the Singleton design pattern.

introduce the keyword DEFINERECORD:

singletonrecord :: Recordtype;
singletonrecord = DEFINERECORD RecordType RecordConstructor { john :: Int = 1, paul :: String = "bass", george :: Bool = True, ringo :: Float = 1.0};

the benefit of this syntax is that the field types and their corresponding values get defined next to each other.  future code changes to type and value will happen at the same place.  there is less danger of accidentally leaving a field uninitialized.

also, the field labels are each written exactly once (Don't Repeat Yourself), in contrast to the current method (below), defining the data type then defining the singleton record using record syntax, which requires typing each field label twice.  although you can optionally put type annotations on field values so that field, value, and type are next to each other when defining the singleton, it feels like even more Repeating Yourself.

data RecordType = RecordConstructor { john :: Int, paul :: String, george :: Bool, ringo :: Float };
singletonrecord :: Recordtype;
singletonrecord = RecordConstructor { john = 1 :: Int, paul = "bass" :: String, george = True :: Bool, ringo = 1 :: Float};

the proposed syntax cannot be used if RecordType has multiple constructors.  (because there can only be one constructor, also consider simpler syntax which restricts the constructor to be the same as that of the type.)

if you have nested records, the syntax can define inner record types "in place" as well.

singletonrecord :: Recordtype;
singletonrecord = DEFINERECORD RecordType RecordConstructor { john :: Int = 1, paul :: String = "bass", george :: Bool = True, ringo = DEFINERECORD DrumType DrumConstructor { snare :: Double = 1.0, cymbal :: String = "crash" } };

this might be a nice feature to combine with Data.Default .

slight variation: record types can be unnamed (anonymous), but have named accessor functions (named fields).  introduce the keyword UNNAMEDRECORD, which stands for both type and constructor.

f1 :: UNNAMEDRECORD;
f1 = UNNAMEDRECORD { john :: String = "guitar", paul :: String = "bass", george :: String = "guitar", ringo = UNNAMEDRECORD { snare :: Double = 1.0, cymbal :: String = "crash" } };

f2 :: UNNAMEDRECORD;
f2 = UNNAMEDRECORD { capital :: String = "london", home :: String = "liverpool" };

g :: String;
g = let
{ v1 :: UNNAMEDRECORD
; v1 = f1
; v2 :: UNNAMEDRECORD
; v2 = f2
} in cymbal (ringo v1) ++ home v2;
-- returns "crashliverpool"

this is better than returning multiple values through tuple syntax because components get named, both when creating and extracting.  using names seems less error-prone than extracting tuple components by position:

g = let { v1 = f1 ; v2 = f2 } in (case v1 of {(_,_,_, (_,x) )->x}) ++ snd v2

open question: if we use DEFINERECORD or UNNAMEDRECORD inside a let or where, should the type name and accessor functions escape the let and become visible in the global scope?  perhaps explicitly mark things for export from the let (requires more new syntax).

more sophistication (and complexity) possible: lenses, record wildcards and puns, etc.  type inference probably becomes more difficult.

related work by Alexander Thiemann: SuperRecord anonymous records.

although we propose this extension for Haskell, it seems a nice feature to have in any programming language.

Wednesday, January 22, 2025

[kufstdwm] alpha-beta with transposition table as a library function

transposition table is the other elegant improvement to minimax (after alpha-beta): elegant in principle, hairy to implement in practice.

consider a generic implementation of alpha-beta game tree search with transposition table, generic enough to be applicable to any user-specified game.  what should be its API?  what features should it provide?

evaluate to infinite depth (possible because of transposition table), returning game value and line (principal variation).  intended for small games.

return the transposition table so that it can be reused for subsequent moves.

evaluate to given depth.  or, user-specified predicate of whether to stop searching, e.g., quiescence search.  quiescence search wants access to the transposition table.

ambitious: because of the many ways game tree search can be customized (for many examples, albeit often poorly described, see the chessprogramming wiki), structure the algorithm as a collection components each of which can be modified and hooked together in various ways.  I have no idea what language or framework could enable this kind of software engineering, though functional programming languages seem attractive as the first thing to try.  but beware that a pure functional programming language such as Haskell easily leaks space for this kind of task, and threading state, the transposition table, though the computation may be awkward.

common customizations sacrifice accuracy (correctness or completeness) for speed.  for example, if two different evaluated positions have the same key (for example, a 64-bit Zobrist hash in chess), one can optimize by doing no transposition table collision resolution; the second position gets ignored, assumed to have already been evaluated.  the default algorithm should not do such optimizations but should allow the user to specify both safe and unsafe optimizations.

allow the search to be augmented with various statistics gathered along the way that get consumed by other user-specified parts of the algorithm.  for example, the move generator could order moves based on values of similar moves already evaluated in other parts of the tree.

provide visibility into how user customizations are working, ways to evaluate whether or not they are worth it.

Wednesday, October 02, 2024

[mlzpqxqu] import with type signature

proposal for a Haskell language extension: when importing a function from another module, one may optionally also specify a type signature for the imported function.  this would be helpful for code understanding.  the reader would have immediately available the type of the imported symbol, not having to go track down the type in the source module (which may be many steps away when modules re-export symbols, and the source module might not even have a type annotation), nor use a tool such as ghci to query it.  (maybe the code currently fails to compile for other reasons, so ghci is not available.)

if a function with the specified type signature is not exported by an imported module, the compiler can offer suggestions of other functions exported by the module which do have, or unify with, the imported type signature.  maybe the function got renamed in a new version of the module.

or, the compiler can do what Hoogle does and search among all modules in its search path for functions with the given signature.  maybe the function got moved to a different module.

the specified type signature may be narrower than how the function was originally defined.  this can limit some of the insanity caused by the Foldable Traversable Proposal (FTP):

import Prelude(length :: [a] -> Int) -- prevent length from being called on tuples and Maybe

various potentially tricky issues:

  1. a situation similar to the diamond problem (multiple inheritance) in object-oriented programming: module A defines a polymorphic function f, imported then re-exported by modules B and C.  module D imports both B and C, unqualified.  B imports and re-exports f from A with a type signature more narrow than originally defined in A.  C does not change the type signature.  what is the type of f as seen by D?  which version of f, which path through B or C, does D see?  solution might be simple: if the function through different paths are not identical, then the user has to qualify.

  2. the following tries to make List.length available only for lists, and Foldable.length available for anything else.  is this asking for trouble?

    import Prelude hiding(length);
    import qualified Prelude(length :: [a] -> Int) as List;
    import qualified Prelude(length) as Foldable;

Wednesday, June 12, 2024

[vkhdrcsg] encoding number size with digit grouping

grouping chunks of digits with commas the standard way makes it easier to tell how large a number is:

1 digit number: 1
2 digits: 22
3 digits: 333
4 digits: 1,333
5 digits: 22,333
6 digits: 333,333
7 digits: 1,333,333
8 digits: 22,333,333
9 digits: 333,333,333
10 digits: 1,333,333,333
11 digits: 22,333,333,333

however, when numbers get even larger, it becomes hard to count the number of groups of 3.  we propose a non-uniform grouping of digits to make counting slightly easier.

the general idea is as follows:

1 + 1 + 1 + 1 + 3 + 3 = 10
10 + 10 + 10 + 10 + 30 + 30 = 100
(1 + 1 + 1 + 1 + 3 + 3) + 10 + 10 + 10 + 30 + 30 = 100

in the third line above, we have substituted the first line into the first "10" in the second line.  this can be continued recursively for larger powers of 10.  (previously, powers of 2.)  groupings of 1, 3, 10, 30, 100, 300, and so forth allow identifying chunks of a power of 10 digits.

here are sample numbers of 1 through 10 digits with inserted commas.  (special cases: optionally omitting commas for numbers of 1 through 4 digits.)

1 digit: 1
2 digits: 1,1 (or 11)
3 digits: 1,1,1 (or 111)
4 digits: 1,1,1,1 (or 1111)
5 digits: 1,1,333
6 digits: 1,1,1,333
7 digits: 1,1,1,1,333
8 digits: 1,1,333,333
9 digits: 1,1,1,333,333
10 digits: 1,1,1,1,333,333

if a number grows or shrinks by one digit, the comma pattern can radically change, as it does between 4 and 5 digits, and between 7 and 8.  this might be confusing compared to the standard system of groups of 3.  but radical change in appearance when a number has changed by a factor of 10 might be beneficial.

(the Indian numbering system (lakh, crore, etc.) has non-uniform digit groupings, though not as extreme as this.)

to handle a number of 10*a + b (a<10) digits, first add commas to the first 10*a digits by itself, then recursively the next b digits, then concatenate.  in other words, treat the length one digit at a time.  in the examples below (and above), for ease of understanding, we also give the number of digits in each digit grouping as the digits of that grouping.

11 digits: 1,1,1,1,333,333,1
12 digits: 1,1,1,1,333,333,1,1
13 digits: 1,1,1,1,333,333,1,1,1
14 digits: 1,1,1,1,333,333,1,1,1,1
15 digits: 1,1,1,1,333,333,1,1,333
16 digits: 1,1,1,1,333,333,1,1,1,333
17 digits: 1,1,1,1,333,333,1,1,1,1,333
18 digits: 1,1,1,1,333,333,1,1,333,333
19 digits: 1,1,1,1,333,333,1,1,1,333,333
20 digits: 1,1,1,1,333,333,1010101010
21 digits: 1,1,1,1,333,333,1010101010,1
22 digits: 1,1,1,1,333,333,1010101010,1,1
23 digits: 1,1,1,1,333,333,1010101010,1,1,1
24 digits: 1,1,1,1,333,333,1010101010,1,1,1,1
25 digits: 1,1,1,1,333,333,1010101010,1,1,333
26 digits: 1,1,1,1,333,333,1010101010,1,1,1,333
27 digits: 1,1,1,1,333,333,1010101010,1,1,1,1,333
28 digits: 1,1,1,1,333,333,1010101010,1,1,333,333
29 digits: 1,1,1,1,333,333,1010101010,1,1,1,333,333
30 digits: 1,1,1,1,333,333,1010101010,1010101010
31 digits: 1,1,1,1,333,333,1010101010,1010101010,1

the length of a number can therefore be read off one digit at a time.  if a digit group size increases, it  increases only by 3 or 10/3 .  the next digit of the length begins when the grouping size decreases to one: ",X,".  this resembles the "ladders" in a previous post about digit sequences.  (originally those digit sequences were developed to serve as sample digit groups for this post, but 333 and 1010101010 etc. ended up being simpler.)

(counterpoint: for just communicating the size of a number, much simpler than the madness proposed here is scientific notation: 120000 = 1.2e5)

below are the sizes of digit groups for numbers whose number of digits is of the form d*10^n .

1 digit: 1
2 digits: 1 1
3 digits: 1 1 1
4 digits: 1 1 1 1
5 digits: 1 1 3
6 digits: 1 1 1 3
7 digits: 1 1 1 1 3
8 digits: 1 1 3 3
9 digits: 1 1 1 3 3
10 digits: 1 1 1 1 3 3
20 digits: 1 1 1 1 3 3 10
30 digits: 1 1 1 1 3 3 10 10
40 digits: 1 1 1 1 3 3 10 10 10
50 digits: 1 1 1 1 3 3 10 30
60 digits: 1 1 1 1 3 3 10 10 30
70 digits: 1 1 1 1 3 3 10 10 10 30
80 digits: 1 1 1 1 3 3 10 30 30
90 digits: 1 1 1 1 3 3 10 10 30 30
100 digits: 1 1 1 1 3 3 10 10 10 30 30
200 digits: 1 1 1 1 3 3 10 10 10 30 30 100
300 digits: 1 1 1 1 3 3 10 10 10 30 30 100 100
400 digits: 1 1 1 1 3 3 10 10 10 30 30 100 100 100
500 digits: 1 1 1 1 3 3 10 10 10 30 30 100 300
600 digits: 1 1 1 1 3 3 10 10 10 30 30 100 100 300
700 digits: 1 1 1 1 3 3 10 10 10 30 30 100 100 100 300
800 digits: 1 1 1 1 3 3 10 10 10 30 30 100 300 300
900 digits: 1 1 1 1 3 3 10 10 10 30 30 100 100 300 300
1000 digits: 1 1 1 1 3 3 10 10 10 30 30 100 100 100 300 300
2000 digits: 1 1 1 1 3 3 10 10 10 30 30 100 100 100 300 300 1000
3000 digits: 1 1 1 1 3 3 10 10 10 30 30 100 100 100 300 300 1000 1000
4000 digits: 1 1 1 1 3 3 10 10 10 30 30 100 100 100 300 300 1000 1000 1000
5000 digits: 1 1 1 1 3 3 10 10 10 30 30 100 100 100 300 300 1000 3000
6000 digits: 1 1 1 1 3 3 10 10 10 30 30 100 100 100 300 300 1000 1000 3000
7000 digits: 1 1 1 1 3 3 10 10 10 30 30 100 100 100 300 300 1000 1000 1000 3000
8000 digits: 1 1 1 1 3 3 10 10 10 30 30 100 100 100 300 300 1000 3000 3000
9000 digits: 1 1 1 1 3 3 10 10 10 30 30 100 100 100 300 300 1000 1000 3000 3000

for example, the digit grouping of a 555-digit number is first the digit grouping of a 500-digit number, 1 1 1 1 3 3 10 10 10 30 30 100 300 , then the digit grouping of a 50-digit number 1 1 1 1 3 3 10 30 , then the digit grouping of a 5 digit number, 1 1 3 , so the entire digit grouping is 1 1 1 1 3 3 10 10 10 30 30 100 300 1 1 1 1 3 3 10 30 1 1 3 .  here is an example 555-digit number with commas so inserted:

1,1,1,1,333,333,1010101010,1010101010,1010101010,303030303030303030303030303030,303030303030303030303030303030,1001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001,300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300300,1,1,1,1,333,333,1010101010,303030303030303030303030303030,1,1,333

here is a sample 105-digit number, illustrating that nothing special happens when the length has an internal zero.  the digit grouping is 1 1 1 1 3 3 10 10 10 30 30 1 1 3:

1,1,1,1,333,333,1010101010,1010101010,1010101010,303030303030303030303030303030,303030303030303030303030303030,1,1,333

because internal digit chunks can get arbitrarily long, this method of grouping is not helpful for providing visual breaks for a human reading or transcribing the digits.  it is not too helpful for locating a particular digit by index.  previously, varied separator characters to solve these problems.

source code in Haskell to generate digit group sizes and perform groupings.

Thursday, November 30, 2023

[iuigljdm] and (False,True)

some more silliness resulting from the Foldable Traversable Proposal (FTP) in Haskell:

*Main> and (False,True)
True
*Main> and [False,True]
False
*Main> uncurry (&&) (False,True)
False
*Main> snd (False,True)
True

"and" may be called on a tuple because tuples are instances of Foldable.  this is similar to length (1,2) == 1.

"and" == "snd" was discovered by accident.  I had accidentally typed "and" instead of "snd" (A and S are adjacent on a QWERTY keyboard), calling it on an argument of type (a,Bool).  despite the typo, seemingly substituting functions of completely different types, the program compiled and ran successfully.  I think "and" and "snd" always give the same answer for inputs of type (a,Bool).

Wednesday, December 21, 2022

[duartbli] Digit strings easy to count their length

It is easy to count the length of the following digit strings:

1
12
123
...
123456789
1234567890
12345678901
123456789012
...
1234567890123456789

Strings like these can serve as example input when it is useful to communicate the length of the string but the content of the string is not important, for example, an example block of data encoded in base 10 (future post vkhdrcsg).  Each string documents its own length.

For strings of lengths 20-29, we write the length-10 string above, then ten 2s, then up to 9 digits:

12345678902222222222
123456789022222222221
1234567890222222222212
...
12345678902222222222123456789

You have to trust that there are ten 2s.  Strings of length 30-39 follow the pattern:

123456789022222222223333333333
1234567890222222222233333333331
12345678902222222222333333333312
...
123456789022222222223333333333123456789

For expository purposes only, we introduce the shorthand (3x10) to indicate ten 3s.  So the above strings of length 30-39 we express as

1234567890(2x10)(3x10)
1234567890(2x10)(3x10)1
1234567890(2x10)(3x10)12
...
1234567890(2x10)(3x10)123456789

This shorthand will become especially useful when we explain longer strings.

The pattern easily extends up to strings of length 99.

Strings of length 10-19 are not (1x10)12345... because 10 and 11 would be difficult to distinguish:

1111111111 11111111111

Replacing long strings of 1s with ascending digits will also become useful later in creating a "ladder".

The first idea for 100 is (1x100), but that has same difficulty as 10-11 for strings of length 101.  Next we try (1x10)(2x10)(3x10)(4x10)(5x10)(6x10)(7x10)(8x10)(9x10)(0x10).  We then replace the initial (1x10) with 1234567890 as we did for 10-19, for reasons we will explain shortly, yielding

1234567890(2x10)(3x10)(4x10)(5x10)(6x10)(7x10)(8x10)(9x10)(0x10)

For strings of length 101-199, we simply append the strings of length 1-99 to the right of the above string.

The strings of length 200-299 has the string of length 100 from above, then (2x100), then the string of length 1-99.  You have to trust that there are 100 2s.  For example, the string of length 200:

1234567890(2x10)(3x10)(4x10)(5x10)(6x10)(7x10)(8x10)(9x10)(0x10)(2x100)

Then we can similarly construct strings of length 300-999 as we did for 30-99.

The string of length 1000 is

1234567890(2x10)(3x10)(4x10)(5x10)(6x10)(7x10)(8x10)(9x10)(0x10)(2x100)(3x100)(4x100)(5x100)(6x100)(7x100)(8x100)(9x100)(0x100)

One can see the recursive structure. The string of length 1000 has the string of length 100 at its beginning, which in turn has the string of length 10 at its beginning.  This "ladder" of more and more stretched out versions of 1234567890 lets you determine what power of 10 you are dealing with by counting the number of recursions.  If we were not to do this, it would be difficult to distinguish between (say) one thousand and ten thousand 1s.  Once we know what power of 10 we are at -- what rung of the ladder we are at -- we can assume that the following long strings of 2s, 3s, etc. each have the same length.

Here is the string of length 1023, illustrating how nothing interesting happens when the length has an internal zero digit:

1234567890(2x10)(3x10)(4x10)(5x10)(6x10)(7x10)(8x10)(9x10)(0x10)(2x100)(3x100)(4x100)(5x100)(6x100)(7x100)(8x100)(9x100)(0x100)1234567890(2x10)123

The string of length 2000 is

1234567890(2x10)(3x10)(4x10)(5x10)(6x10)(7x10)(8x10)(9x10)(0x10)(2x100)(3x100)(4x100)(5x100)(6x100)(7x100)(8x100)(9x100)(0x100)(2x1000)

There will be multiple ladders, one for each nonzero digit in the length of a string.  The string 1234567890 indicates that the previous digit in the length is complete and a new ladder is beginning.  Here is the string of length 2345:

1234567890(2x10)(3x10)(4x10)(5x10)(6x10)(7x10)(8x10)(9x10)(0x10)(2x100)(3x100)(4x100)(5x100)(6x100)(7x100)(8x100)(9x100)(0x100)(2x1000)1234567890(2x10)(3x10)(4x10)(5x10)(6x10)(7x10)(8x10)(9x10)(0x10)(2x100)(3x100)1234567890(2x10)(3x10)(4x10)12345

If possible, text figures (lowercase numerals) should be used to make it easy to spot the beginning of ladders and where digits change.

Haskell source to construct these strings in any base.  Here are the two key routines:

-- expand by 10
dogrow :: Integer -> Char -> String;
dogrow base '1' = List.genericTake (base-1) positive_digits ++ "0";
dogrow base c = List.genericReplicate base c;

-- process little-endian input one digit at a time
growasdigits :: Integer -> [Integer] -> String;
growasdigits _base [] = "";
growasdigits base (h:t) = (growasdigits base t & concatMap (dogrow base)) ++ List.genericTake h positive_digits;

Future work: parser to verify correctness of a string.

Below is the construction in base 4 instead of base 10, showing strings of length 1 through 70.  The first column is string lengths expressed in base 4.

11
212
3123
101230
1112301
12123012
131230123
2012302222
21123022221
221230222212
2312302222123
30123022223333
311230222233331
3212302222333312
33123022223333123
1001230222233330000
10112302222333300001
102123022223333000012
1031230222233330000123
11012302222333300001230
111123022223333000012301
1121230222233330000123012
11312302222333300001230123
120123022223333000012302222
1211230222233330000123022221
12212302222333300001230222212
123123022223333000012302222123
1301230222233330000123022223333
13112302222333300001230222233331
132123022223333000012302222333312
1331230222233330000123022223333123
20012302222333300002222222222222222
201123022223333000022222222222222221
2021230222233330000222222222222222212
20312302222333300002222222222222222123
210123022223333000022222222222222221230
2111230222233330000222222222222222212301
21212302222333300002222222222222222123012
213123022223333000022222222222222221230123
2201230222233330000222222222222222212302222
22112302222333300002222222222222222123022221
222123022223333000022222222222222221230222212
2231230222233330000222222222222222212302222123
23012302222333300002222222222222222123022223333
231123022223333000022222222222222221230222233331
2321230222233330000222222222222222212302222333312
23312302222333300002222222222222222123022223333123
300123022223333000022222222222222223333333333333333
3011230222233330000222222222222222233333333333333331
30212302222333300002222222222222222333333333333333312
303123022223333000022222222222222223333333333333333123
3101230222233330000222222222222222233333333333333331230
31112302222333300002222222222222222333333333333333312301
312123022223333000022222222222222223333333333333333123012
3131230222233330000222222222222222233333333333333331230123
32012302222333300002222222222222222333333333333333312302222
321123022223333000022222222222222223333333333333333123022221
3221230222233330000222222222222222233333333333333331230222212
32312302222333300002222222222222222333333333333333312302222123
330123022223333000022222222222222223333333333333333123022223333
3311230222233330000222222222222222233333333333333331230222233331
33212302222333300002222222222222222333333333333333312302222333312
333123022223333000022222222222222223333333333333333123022223333123
10001230222233330000222222222222222233333333333333330000000000000000
100112302222333300002222222222222222333333333333333300000000000000001
1002123022223333000022222222222222223333333333333333000000000000000012
10031230222233330000222222222222222233333333333333330000000000000000123
101012302222333300002222222222222222333333333333333300000000000000001230
1011123022223333000022222222222222223333333333333333000000000000000012301
10121230222233330000222222222222222233333333333333330000000000000000123012

Friday, October 14, 2022

[ykoqomhu] summing reciprocals minimizing round-off error

to decrease round-off error when summing a collection of positive floating-point numbers, sum numbers from smallest to largest.  however, it is not as simple as just first sorting the input list: a partial sum could become large compared to the next number to be added.  better is to put all the numbers in a priority queue (heap), then repeatedly pop off the two smallest numbers, add them, and push them back into the priority queue.  (increased precision comes at the cost of a factor of log n time.)  we demonstrate this in Haskell, using Data.PQueue.Min in the pqueue package as our priority queue.  we sum exact Rational numbers for simplicity, and we keep track of what got added to what in an expression tree.

future work: keep track of roundoff error.

(related work, not implemented here: Kahan summation is another way to decrease round-off error.  Kahan was previously mentioned in the context of trying to avoid catastrophic loss of precision when doing trigonometry.)

source code.

here is the tail-recursive function that sums the contents of a priority queue.

reduceto1 :: Pqueue.MinQueue Expr -> Expr;
reduceto1 q = let {
  (a::Expr, q2) = Pqueue.deleteFindMin q
} in case Pqueue.minView q2 of {
  Nothing -> a;
  Just(b::Expr, q3) -> reduceto1 $ flip Pqueue.insert q3 $ Plus a b; -- smaller number on the left side of the plus sign
};

first, we demonstrate adding the first N reciprocals of integers (partial sums of the harmonic series).

1: 1/1

2: (1/2 + 1/1)

3: ((1/3 + 1/2) + 1/1)

4: (1/1 + (1/2 + (1/4 + 1/3)))

5: (1/1 + (1/2 + (1/3 + (1/5 + 1/4))))

6: (1/1 + ((1/4 + 1/3) + ((1/6 + 1/5) + 1/2)))

7: (1/1 + (((1/7 + 1/6) + 1/3) + ((1/5 + 1/4) + 1/2)))

8: ((1/2 + (1/4 + (1/8 + 1/7))) + ((1/3 + (1/6 + 1/5)) + 1/1))

9: ((1/2 + (1/4 + (1/7 + 1/6))) + ((1/3 + (1/5 + (1/9 + 1/8))) + 1/1))

10: ((1/2 + ((1/8 + 1/7) + 1/3)) + (((1/6 + 1/5) + ((1/10 + 1/9) + 1/4)) + 1/1))

11: ((1/2 + ((1/7 + 1/6) + 1/3)) + ((((1/11 + 1/10) + 1/5) + ((1/9 + 1/8) + 1/4)) + 1/1))

12: (((1/4 + (1/8 + 1/7)) + (1/3 + (1/6 + (1/12 + 1/11)))) + (((1/5 + (1/10 + 1/9)) + 1/2) + 1/1))

13: (((1/4 + (1/7 + (1/13 + 1/12))) + (1/3 + (1/6 + (1/11 + 1/10)))) + (((1/5 + (1/9 + 1/8)) + 1/2) + 1/1))

14: ((((1/8 + 1/7) + ((1/14 + 1/13) + 1/6)) + (1/3 + ((1/12 + 1/11) + 1/5))) + ((((1/10 + 1/9) + 1/4) + 1/2) + 1/1))

15: (((((1/15 + 1/14) + 1/7) + ((1/13 + 1/12) + 1/6)) + (1/3 + ((1/11 + 1/10) + 1/5))) + ((((1/9 + 1/8) + 1/4) + 1/2) + 1/1))

16: ((((1/7 + (1/14 + 1/13)) + 1/3) + ((1/6 + (1/12 + 1/11)) + (1/5 + (1/10 + 1/9)))) + (1/1 + (1/2 + (1/4 + (1/8 + (1/16 + 1/15))))))

17: ((((1/7 + (1/13 + 1/12)) + 1/3) + ((1/6 + (1/11 + 1/10)) + (1/5 + (1/9 + (1/17 + 1/16))))) + (1/1 + (1/2 + (1/4 + (1/8 + (1/15 + 1/14))))))

18: (((((1/14 + 1/13) + 1/6) + 1/3) + (((1/12 + 1/11) + 1/5) + ((1/10 + 1/9) + ((1/18 + 1/17) + 1/8)))) + (1/1 + (1/2 + (1/4 + ((1/16 + 1/15) + 1/7)))))

19: (((((1/13 + 1/12) + 1/6) + 1/3) + (((1/11 + 1/10) + 1/5) + (((1/19 + 1/18) + 1/9) + ((1/17 + 1/16) + 1/8)))) + (1/1 + (1/2 + (1/4 + ((1/15 + 1/14) + 1/7)))))

20: (((1/3 + (1/6 + (1/12 + 1/11))) + ((1/5 + (1/10 + (1/20 + 1/19))) + ((1/9 + (1/18 + 1/17)) + 1/4))) + (1/1 + (1/2 + ((1/8 + (1/16 + 1/15)) + (1/7 + (1/14 + 1/13))))))

21: (((1/3 + (1/6 + (1/11 + (1/21 + 1/20)))) + ((1/5 + (1/10 + (1/19 + 1/18))) + ((1/9 + (1/17 + 1/16)) + 1/4))) + (1/1 + (1/2 + ((1/8 + (1/15 + 1/14)) + (1/7 + (1/13 + 1/12))))))

22: (((1/3 + ((1/12 + 1/11) + ((1/22 + 1/21) + 1/10))) + ((1/5 + ((1/20 + 1/19) + 1/9)) + (((1/18 + 1/17) + 1/8) + 1/4))) + (1/1 + (1/2 + (((1/16 + 1/15) + 1/7) + ((1/14 + 1/13) + 1/6)))))

23: (((1/3 + (((1/23 + 1/22) + 1/11) + ((1/21 + 1/20) + 1/10))) + ((1/5 + ((1/19 + 1/18) + 1/9)) + (((1/17 + 1/16) + 1/8) + 1/4))) + (1/1 + (1/2 + (((1/15 + 1/14) + 1/7) + ((1/13 + 1/12) + 1/6)))))

24: ((((1/6 + (1/12 + (1/24 + 1/23))) + ((1/11 + (1/22 + 1/21)) + 1/5)) + (((1/10 + (1/20 + 1/19)) + (1/9 + (1/18 + 1/17))) + 1/2)) + (1/1 + ((1/4 + (1/8 + (1/16 + 1/15))) + ((1/7 + (1/14 + 1/13)) + 1/3))))

25: ((((1/6 + (1/12 + (1/23 + 1/22))) + ((1/11 + (1/21 + 1/20)) + 1/5)) + (((1/10 + (1/19 + 1/18)) + (1/9 + (1/17 + 1/16))) + 1/2)) + (1/1 + ((1/4 + (1/8 + (1/15 + 1/14))) + ((1/7 + (1/13 + (1/25 + 1/24))) + 1/3))))

26: ((((1/6 + ((1/24 + 1/23) + 1/11)) + (((1/22 + 1/21) + 1/10) + 1/5)) + ((((1/20 + 1/19) + 1/9) + ((1/18 + 1/17) + 1/8)) + 1/2)) + (1/1 + ((1/4 + ((1/16 + 1/15) + 1/7)) + (((1/14 + 1/13) + ((1/26 + 1/25) + 1/12)) + 1/3))))

27: ((((1/6 + ((1/23 + 1/22) + 1/11)) + (((1/21 + 1/20) + 1/10) + 1/5)) + ((((1/19 + 1/18) + 1/9) + ((1/17 + 1/16) + 1/8)) + 1/2)) + (1/1 + ((1/4 + ((1/15 + 1/14) + 1/7)) + ((((1/27 + 1/26) + 1/13) + ((1/25 + 1/24) + 1/12)) + 1/3))))

28: (((((1/12 + (1/24 + 1/23)) + (1/11 + (1/22 + 1/21))) + (1/5 + (1/10 + (1/20 + 1/19)))) + (((1/9 + (1/18 + 1/17)) + 1/4) + 1/2)) + (1/1 + (((1/8 + (1/16 + 1/15)) + (1/7 + (1/14 + (1/28 + 1/27)))) + (((1/13 + (1/26 + 1/25)) + 1/6) + 1/3))))

29: (((((1/12 + (1/23 + 1/22)) + (1/11 + (1/21 + 1/20))) + (1/5 + (1/10 + (1/19 + 1/18)))) + (((1/9 + (1/17 + 1/16)) + 1/4) + 1/2)) + (1/1 + (((1/8 + (1/15 + (1/29 + 1/28))) + (1/7 + (1/14 + (1/27 + 1/26)))) + (((1/13 + (1/25 + 1/24)) + 1/6) + 1/3))))

30: ((((((1/24 + 1/23) + 1/11) + ((1/22 + 1/21) + 1/10)) + (1/5 + ((1/20 + 1/19) + 1/9))) + ((((1/18 + 1/17) + 1/8) + 1/4) + 1/2)) + (1/1 + ((((1/16 + 1/15) + ((1/30 + 1/29) + 1/14)) + (1/7 + ((1/28 + 1/27) + 1/13))) + ((((1/26 + 1/25) + 1/12) + 1/6) + 1/3))))

31: ((((((1/23 + 1/22) + 1/11) + ((1/21 + 1/20) + 1/10)) + (1/5 + ((1/19 + 1/18) + 1/9))) + ((((1/17 + 1/16) + 1/8) + 1/4) + 1/2)) + (1/1 + (((((1/31 + 1/30) + 1/15) + ((1/29 + 1/28) + 1/14)) + (1/7 + ((1/27 + 1/26) + 1/13))) + ((((1/25 + 1/24) + 1/12) + 1/6) + 1/3))))

32: (((((1/11 + (1/22 + 1/21)) + 1/5) + ((1/10 + (1/20 + 1/19)) + (1/9 + (1/18 + 1/17)))) + 1/1) + ((1/2 + (1/4 + (1/8 + (1/16 + (1/32 + 1/31))))) + ((((1/15 + (1/30 + 1/29)) + 1/7) + ((1/14 + (1/28 + 1/27)) + (1/13 + (1/26 + 1/25)))) + (1/3 + (1/6 + (1/12 + (1/24 + 1/23)))))))

33: (((((1/11 + (1/21 + 1/20)) + 1/5) + ((1/10 + (1/19 + 1/18)) + (1/9 + (1/17 + (1/33 + 1/32))))) + 1/1) + ((1/2 + (1/4 + (1/8 + (1/16 + (1/31 + 1/30))))) + ((((1/15 + (1/29 + 1/28)) + 1/7) + ((1/14 + (1/27 + 1/26)) + (1/13 + (1/25 + 1/24)))) + (1/3 + (1/6 + (1/12 + (1/23 + 1/22)))))))

34: ((((((1/22 + 1/21) + 1/10) + 1/5) + (((1/20 + 1/19) + 1/9) + ((1/18 + 1/17) + ((1/34 + 1/33) + 1/16)))) + 1/1) + ((1/2 + (1/4 + (1/8 + ((1/32 + 1/31) + 1/15)))) + (((((1/30 + 1/29) + 1/14) + 1/7) + (((1/28 + 1/27) + 1/13) + ((1/26 + 1/25) + 1/12))) + (1/3 + (1/6 + ((1/24 + 1/23) + 1/11))))))

35: ((((((1/21 + 1/20) + 1/10) + 1/5) + (((1/19 + 1/18) + 1/9) + (((1/35 + 1/34) + 1/17) + ((1/33 + 1/32) + 1/16)))) + 1/1) + ((1/2 + (1/4 + (1/8 + ((1/31 + 1/30) + 1/15)))) + (((((1/29 + 1/28) + 1/14) + 1/7) + (((1/27 + 1/26) + 1/13) + ((1/25 + 1/24) + 1/12))) + (1/3 + (1/6 + ((1/23 + 1/22) + 1/11))))))

36: ((((1/5 + (1/10 + (1/20 + 1/19))) + ((1/9 + (1/18 + (1/36 + 1/35))) + ((1/17 + (1/34 + 1/33)) + 1/8))) + 1/1) + ((1/2 + (1/4 + ((1/16 + (1/32 + 1/31)) + (1/15 + (1/30 + 1/29))))) + (((1/7 + (1/14 + (1/28 + 1/27))) + ((1/13 + (1/26 + 1/25)) + 1/6)) + (1/3 + ((1/12 + (1/24 + 1/23)) + (1/11 + (1/22 + 1/21)))))))

37: ((((1/5 + (1/10 + (1/19 + (1/37 + 1/36)))) + ((1/9 + (1/18 + (1/35 + 1/34))) + ((1/17 + (1/33 + 1/32)) + 1/8))) + 1/1) + ((1/2 + (1/4 + ((1/16 + (1/31 + 1/30)) + (1/15 + (1/29 + 1/28))))) + (((1/7 + (1/14 + (1/27 + 1/26))) + ((1/13 + (1/25 + 1/24)) + 1/6)) + (1/3 + ((1/12 + (1/23 + 1/22)) + (1/11 + (1/21 + 1/20)))))))

38: ((((1/5 + ((1/20 + 1/19) + ((1/38 + 1/37) + 1/18))) + ((1/9 + ((1/36 + 1/35) + 1/17)) + (((1/34 + 1/33) + 1/16) + 1/8))) + 1/1) + ((1/2 + (1/4 + (((1/32 + 1/31) + 1/15) + ((1/30 + 1/29) + 1/14)))) + (((1/7 + ((1/28 + 1/27) + 1/13)) + (((1/26 + 1/25) + 1/12) + 1/6)) + (1/3 + (((1/24 + 1/23) + 1/11) + ((1/22 + 1/21) + 1/10))))))

39: ((((1/5 + (((1/39 + 1/38) + 1/19) + ((1/37 + 1/36) + 1/18))) + ((1/9 + ((1/35 + 1/34) + 1/17)) + (((1/33 + 1/32) + 1/16) + 1/8))) + 1/1) + ((1/2 + (1/4 + (((1/31 + 1/30) + 1/15) + ((1/29 + 1/28) + 1/14)))) + (((1/7 + ((1/27 + 1/26) + 1/13)) + (((1/25 + 1/24) + 1/12) + 1/6)) + (1/3 + (((1/23 + 1/22) + 1/11) + ((1/21 + 1/20) + 1/10))))))

40: (((((1/10 + (1/20 + (1/40 + 1/39))) + ((1/19 + (1/38 + 1/37)) + 1/9)) + (((1/18 + (1/36 + 1/35)) + (1/17 + (1/34 + 1/33))) + 1/4)) + 1/1) + ((1/2 + ((1/8 + (1/16 + (1/32 + 1/31))) + ((1/15 + (1/30 + 1/29)) + 1/7))) + ((((1/14 + (1/28 + 1/27)) + (1/13 + (1/26 + 1/25))) + 1/3) + ((1/6 + (1/12 + (1/24 + 1/23))) + ((1/11 + (1/22 + 1/21)) + 1/5)))))

next, sums of the reciprocals of the primes up to N.  like the harmonic series, sum diverges when taken over all primes.

2: 1/2

3: (1/3 + 1/2)

5: (1/2 + (1/5 + 1/3))

7: (1/2 + (1/3 + (1/7 + 1/5)))

11: (1/2 + (1/3 + (1/5 + (1/11 + 1/7))))

13: ((1/5 + (1/7 + (1/13 + 1/11))) + (1/3 + 1/2))

17: (((1/11 + (1/17 + 1/13)) + 1/3) + ((1/7 + 1/5) + 1/2))

19: ((((1/19 + 1/17) + 1/7) + 1/3) + (((1/13 + 1/11) + 1/5) + 1/2))

23: ((((1/17 + 1/13) + 1/7) + 1/3) + (((1/11 + (1/23 + 1/19)) + 1/5) + 1/2))

29: (((1/7 + (1/13 + (1/29 + 1/23))) + 1/3) + ((1/5 + (1/11 + (1/19 + 1/17))) + 1/2))

31: (((1/7 + (1/13 + 1/11)) + 1/3) + ((1/5 + ((1/23 + 1/19) + (1/17 + (1/31 + 1/29)))) + 1/2))

37: (((1/7 + ((1/29 + 1/23) + 1/11)) + 1/3) + ((1/5 + ((1/19 + 1/17) + ((1/37 + 1/31) + 1/13))) + 1/2))

41: (((((1/31 + 1/29) + 1/13) + (1/11 + (1/23 + (1/41 + 1/37)))) + 1/3) + ((1/5 + ((1/19 + 1/17) + 1/7)) + 1/2))

43: ((1/3 + ((1/13 + (1/29 + 1/23)) + (1/11 + ((1/43 + 1/41) + 1/19)))) + ((1/5 + ((1/17 + (1/37 + 1/31)) + 1/7)) + 1/2))

47: ((1/3 + ((1/13 + (1/23 + (1/47 + 1/43))) + (1/11 + ((1/41 + 1/37) + 1/19)))) + ((1/5 + ((1/17 + (1/31 + 1/29)) + 1/7)) + 1/2))

53: ((1/3 + ((1/13 + 1/11) + 1/5)) + ((((1/23 + (1/43 + 1/41)) + (1/19 + 1/17)) + (((1/37 + 1/31) + (1/29 + (1/53 + 1/47))) + 1/7)) + 1/2))

59: ((1/3 + ((((1/59 + 1/53) + 1/23) + 1/11) + 1/5)) + (((((1/47 + 1/43) + (1/41 + 1/37)) + (1/19 + 1/17)) + (1/7 + ((1/31 + 1/29) + 1/13))) + 1/2))

61: ((1/3 + ((((1/53 + 1/47) + 1/23) + 1/11) + 1/5)) + (1/2 + ((((1/43 + 1/41) + 1/19) + (1/17 + (1/37 + 1/31))) + (1/7 + (((1/61 + 1/59) + 1/29) + 1/13)))))

67: ((1/3 + (((1/23 + (1/47 + 1/43)) + 1/11) + 1/5)) + (1/2 + ((((1/41 + 1/37) + 1/19) + (1/17 + ((1/67 + 1/61) + 1/31))) + (1/7 + ((1/29 + (1/59 + 1/53)) + 1/13)))))

71: ((1/3 + ((1/11 + (1/23 + (1/43 + 1/41))) + 1/5)) + (1/2 + (((1/19 + (1/37 + (1/71 + 1/67))) + (1/17 + (1/31 + (1/61 + 1/59)))) + (1/7 + ((1/29 + (1/53 + 1/47)) + 1/13)))))

73: ((1/3 + ((1/11 + ((1/47 + 1/43) + (1/41 + 1/37))) + 1/5)) + (1/2 + (((1/19 + 1/17) + (((1/73 + 1/71) + (1/67 + 1/61)) + (1/31 + 1/29))) + (1/7 + (1/13 + ((1/59 + 1/53) + 1/23))))))

79: ((1/3 + ((1/11 + ((1/43 + 1/41) + 1/19)) + 1/5)) + (1/2 + (((((1/79 + 1/73) + 1/37) + 1/17) + (((1/71 + 1/67) + 1/31) + ((1/61 + 1/59) + 1/29))) + (1/7 + (1/13 + ((1/53 + 1/47) + 1/23))))))

83: ((1/3 + ((1/11 + ((1/41 + (1/83 + 1/79)) + 1/19)) + 1/5)) + (1/2 + ((((1/37 + (1/73 + 1/71)) + 1/17) + (((1/67 + 1/61) + 1/31) + (1/29 + (1/59 + 1/53)))) + (1/7 + (1/13 + (1/23 + (1/47 + 1/43)))))))

89: ((1/3 + ((1/11 + ((1/41 + (1/79 + 1/73)) + 1/19)) + 1/5)) + (1/2 + ((((1/37 + (1/71 + 1/67)) + 1/17) + ((1/31 + (1/61 + 1/59)) + (1/29 + (1/53 + 1/47)))) + (1/7 + (1/13 + (1/23 + (1/43 + (1/89 + 1/83))))))))

97: ((1/3 + (((1/23 + (1/43 + 1/41)) + (((1/83 + 1/79) + 1/37) + 1/19)) + 1/5)) + (1/2 + (((1/17 + ((1/73 + 1/71) + (1/67 + 1/61))) + 1/7) + (((1/31 + 1/29) + 1/13) + (((1/59 + 1/53) + (1/47 + (1/97 + 1/89))) + 1/11)))))

101: ((1/3 + ((((1/47 + 1/43) + ((1/89 + 1/83) + 1/41)) + (1/19 + ((1/79 + 1/73) + 1/37))) + 1/5)) + (1/2 + (((1/17 + ((1/71 + 1/67) + 1/31)) + 1/7) + ((((1/61 + 1/59) + 1/29) + 1/13) + (((1/53 + (1/101 + 1/97)) + 1/23) + 1/11)))))

103: ((1/3 + (1/5 + ((((1/97 + 1/89) + 1/43) + (1/41 + (1/83 + 1/79))) + (1/19 + (1/37 + (1/73 + 1/71)))))) + (1/2 + (((1/17 + ((1/67 + 1/61) + 1/31)) + 1/7) + (((1/29 + (1/59 + 1/53)) + 1/13) + ((((1/103 + 1/101) + 1/47) + 1/23) + 1/11)))))

107: ((1/3 + (1/5 + (((1/43 + (1/89 + 1/83)) + (1/41 + (1/79 + 1/73))) + (1/19 + (1/37 + (1/71 + 1/67)))))) + (1/2 + (((1/17 + (1/31 + (1/61 + 1/59))) + 1/7) + (((1/29 + (1/53 + (1/107 + 1/103))) + 1/13) + ((((1/101 + 1/97) + 1/47) + 1/23) + 1/11)))))

109: ((1/3 + (1/5 + (((1/43 + 1/41) + ((1/83 + 1/79) + 1/37)) + (1/19 + 1/17)))) + (1/2 + (((((1/73 + 1/71) + (1/67 + 1/61)) + (1/31 + 1/29)) + 1/7) + ((((1/59 + (1/109 + 1/107)) + (1/53 + (1/103 + 1/101))) + 1/13) + (((1/47 + (1/97 + 1/89)) + 1/23) + 1/11)))))

113: ((1/3 + (1/5 + ((((1/89 + 1/83) + 1/41) + 1/19) + (((1/79 + 1/73) + 1/37) + 1/17)))) + (1/2 + (((((1/71 + 1/67) + 1/31) + ((1/61 + 1/59) + 1/29)) + 1/7) + (((((1/113 + 1/109) + 1/53) + ((1/107 + 1/103) + (1/101 + 1/97))) + 1/13) + ((1/23 + (1/47 + 1/43)) + 1/11)))))

127: ((((1/13 + (((1/109 + 1/107) + 1/53) + ((1/103 + 1/101) + 1/47))) + ((1/23 + ((1/97 + 1/89) + 1/43)) + 1/11)) + (1/5 + (((1/41 + (1/83 + 1/79)) + 1/19) + ((1/37 + (1/73 + 1/71)) + 1/17)))) + (1/2 + (((((1/67 + 1/61) + 1/31) + (((1/127 + 1/113) + 1/59) + 1/29)) + 1/7) + 1/3)))

131: ((((1/13 + ((1/53 + (1/107 + 1/103)) + ((1/101 + 1/97) + 1/47))) + ((1/23 + (1/43 + (1/89 + 1/83))) + 1/11)) + (1/5 + (((1/41 + (1/79 + 1/73)) + 1/19) + ((1/37 + (1/71 + 1/67)) + 1/17)))) + (1/2 + ((((((1/131 + 1/127) + 1/61) + 1/31) + (1/29 + (1/59 + (1/113 + 1/109)))) + 1/7) + 1/3)))

137: ((((1/13 + ((1/53 + (1/103 + 1/101)) + (1/47 + (1/97 + 1/89)))) + (1/11 + (1/23 + (1/43 + 1/41)))) + (1/5 + ((((1/83 + 1/79) + 1/37) + 1/19) + (((1/73 + 1/71) + (1/67 + (1/137 + 1/131))) + 1/17)))) + (1/2 + ((((1/31 + (1/61 + (1/127 + 1/113))) + (1/29 + (1/59 + (1/109 + 1/107)))) + 1/7) + 1/3)))

139: ((((1/13 + (((1/107 + 1/103) + (1/101 + 1/97)) + 1/23)) + (1/11 + ((1/47 + 1/43) + ((1/89 + 1/83) + 1/41)))) + (1/5 + ((1/19 + ((1/79 + 1/73) + 1/37)) + (1/17 + ((1/71 + (1/139 + 1/137)) + (1/67 + (1/131 + 1/127))))))) + (1/2 + ((((1/31 + (1/61 + 1/59)) + (1/29 + ((1/113 + 1/109) + 1/53))) + 1/7) + 1/3)))

149: ((((1/13 + (((1/103 + 1/101) + 1/47) + 1/23)) + (1/11 + (((1/97 + 1/89) + 1/43) + (1/41 + (1/83 + 1/79))))) + (1/5 + ((1/19 + (1/37 + (1/73 + (1/149 + 1/139)))) + (1/17 + ((1/71 + 1/67) + ((1/137 + 1/131) + 1/61)))))) + (1/2 + ((((1/31 + ((1/127 + 1/113) + 1/59)) + (1/29 + ((1/109 + 1/107) + 1/53))) + 1/7) + 1/3)))

151: ((((1/13 + (((1/101 + 1/97) + 1/47) + 1/23)) + (1/11 + ((1/43 + (1/89 + 1/83)) + (1/41 + (1/79 + (1/151 + 1/149)))))) + (1/5 + ((1/19 + (1/37 + (1/73 + 1/71))) + (1/17 + (((1/139 + 1/137) + 1/67) + ((1/131 + 1/127) + 1/61)))))) + (1/2 + ((((1/31 + 1/29) + ((1/59 + (1/113 + 1/109)) + (1/53 + (1/107 + 1/103)))) + 1/7) + 1/3)))

157: ((((1/13 + ((1/47 + (1/97 + 1/89)) + 1/23)) + (1/11 + ((1/43 + 1/41) + ((1/83 + 1/79) + ((1/157 + 1/151) + 1/73))))) + (1/5 + ((1/19 + (1/37 + ((1/149 + 1/139) + 1/71))) + (1/17 + ((1/67 + (1/137 + 1/131)) + 1/31))))) + (1/2 + (((((1/61 + (1/127 + 1/113)) + 1/29) + ((1/59 + (1/109 + 1/107)) + (1/53 + (1/103 + 1/101)))) + 1/7) + 1/3)))

163: ((((1/13 + (1/23 + (1/47 + 1/43))) + (1/11 + (((1/89 + 1/83) + 1/41) + (((1/163 + 1/157) + 1/79) + 1/37)))) + (1/5 + ((1/19 + (((1/151 + 1/149) + 1/73) + (1/71 + (1/139 + 1/137)))) + (1/17 + ((1/67 + (1/131 + 1/127)) + 1/31))))) + (1/2 + ((1/7 + (((1/61 + 1/59) + 1/29) + (((1/113 + 1/109) + 1/53) + ((1/107 + 1/103) + (1/101 + 1/97))))) + 1/3)))

167: (((((((1/109 + 1/107) + 1/53) + ((1/103 + 1/101) + 1/47)) + (1/23 + ((1/97 + 1/89) + 1/43))) + (1/11 + (((1/83 + (1/167 + 1/163)) + 1/41) + 1/19))) + (1/5 + ((((1/79 + (1/157 + 1/151)) + 1/37) + ((1/73 + (1/149 + 1/139)) + (1/71 + 1/67))) + (1/17 + (((1/137 + 1/131) + 1/61) + 1/31))))) + (1/2 + ((1/7 + ((((1/127 + 1/113) + 1/59) + 1/29) + 1/13)) + 1/3)))

173: ((((((1/53 + (1/107 + 1/103)) + ((1/101 + 1/97) + 1/47)) + (1/23 + ((1/89 + (1/173 + 1/167)) + 1/43))) + (1/11 + ((1/41 + (1/83 + (1/163 + 1/157))) + 1/19))) + (1/5 + ((((1/79 + (1/151 + 1/149)) + 1/37) + ((1/73 + 1/71) + ((1/139 + 1/137) + 1/67))) + (1/17 + (((1/131 + 1/127) + 1/61) + 1/31))))) + (1/2 + ((1/7 + ((1/29 + (1/59 + (1/113 + 1/109))) + 1/13)) + 1/3)))

do these expression trees have any rhyme or reason?  the parenthesized representation is not good for seeing structural patterns.  future work: draw them as trees.

the expression trees define a unique binary tree for each integer, or for each prime.

Wednesday, September 07, 2022

[aybvgyej] prime binary truncations

consider a number N.  if N is odd, test whether N is prime.  if N is even, test whether N+1 is prime.  set N := floor(N/2) and repeat primality testing until N=0.  of all the bitwise right shifts, how may are prime?

for example, start at N := 1580011307924772.  N+1 is prime (1)
N := floor(N/2) = 790005653962386.  N+1 is prime (2)
N := floor(N/2) = 395002826981193.
N := floor(N/2) = 197501413490596.  N+1 is prime (3)
N := floor(N/2) = 98750706745298.
N := floor(N/2) = 49375353372649.
N := floor(N/2) = 24687676686324.
N := floor(N/2) = 12343838343162.
N := floor(N/2) = 6171919171581.
N := floor(N/2) = 3085959585790.  N+1 is prime (4)
N := floor(N/2) = 1542979792895.
N := floor(N/2) = 771489896447.  N is prime (5)
N := floor(N/2) = 385744948223.  N is prime (6)
N := floor(N/2) = 192872474111.  N is prime (7)
N := floor(N/2) = 96436237055.
N := floor(N/2) = 48218118527.  N is prime (8)
N := floor(N/2) = 24109059263.  N is prime (9)
N := floor(N/2) = 12054529631.
N := floor(N/2) = 6027264815.
N := floor(N/2) = 3013632407.  N is prime (10)
N := floor(N/2) = 1506816203.  N is prime (11)
N := floor(N/2) = 753408101.  N is prime (12)
N := floor(N/2) = 376704050.
N := floor(N/2) = 188352025.
N := floor(N/2) = 94176012.  N+1 is prime (13)
N := floor(N/2) = 47088006.  N+1 is prime (14)
N := floor(N/2) = 23544003.
N := floor(N/2) = 11772001.
N := floor(N/2) = 5886000.
N := floor(N/2) = 2943000.  N+1 is prime (15)
N := floor(N/2) = 1471500.  N+1 is prime (16)
N := floor(N/2) = 735750.  N+1 is prime (17)
N := floor(N/2) = 367875.
N := floor(N/2) = 183937.
N := floor(N/2) = 91968.  N+1 is prime (18)
N := floor(N/2) = 45984.
N := floor(N/2) = 22992.  N+1 is prime (19)
N := floor(N/2) = 11496.  N+1 is prime (20)
N := floor(N/2) = 5748.  N+1 is prime (21)
N := floor(N/2) = 2874.
N := floor(N/2) = 1437.
N := floor(N/2) = 718.  N+1 is prime (22)
N := floor(N/2) = 359.  N is prime (23)
N := floor(N/2) = 179.  N is prime (24)
N := floor(N/2) = 89.  N is prime (25)
N := floor(N/2) = 44.
N := floor(N/2) = 22.  N+1 is prime (26)
N := floor(N/2) = 11.  N is prime (27)
N := floor(N/2) = 5.  N is prime (28)
N := floor(N/2) = 2.  N+1 is prime (29)
N := floor(N/2) = 1.
N := floor(N/2) = 0.

thus, the number produces 29 primes, which is the most (a record) among numbers up to that starting N.

when examining N=1, we've arbitrarily chosen not to count N+1 = 2 being prime.

previously, factoring truncations of irrational numbers in binary.

the Pari/GP code below is brute force for pedagogical purposes:

countp(p)=my(numprimes=0); my(bitwidth=0); while(p>0, if(p%2, if(isprime(p), numprimes+=1); p=(p-1)/2, if(isprime(p+1), numprimes+=1); p/=2); bitwidth+=1); [numprimes, bitwidth]

best=0; for(n=0,+oo, a=countp(n); if(a[1]>best, best=a[1]; printbinary(n); print(" ",n," ",a," ",n+1)))

here are starting N which set records of producing increasing number of primes.  we give the number in binary (using period to signify zero) (illustrating rich veins of primes which work for a while, peter out, and later revive), in decimal, the number of primes, starting bitwidth, and N+1 (which I think is always prime).

1. 2 [1, 2] 3
1.. 4 [2, 3] 5
1.1. 10 [3, 4] 11
1.11. 22 [4, 5] 23
1.111. 46 [5, 6] 47
1.1..11. 166 [6, 8] 167
1.11..11. 358 [7, 9] 359
1.11..111. 718 [8, 10] 719
1.11..1111. 1438 [9, 11] 1439
1.11..11111. 2878 [10, 12] 2879
1.11..1111111. 11518 [11, 14] 11519
1.11..11111111. 23038 [12, 15] 23039
1.11..11111111... 92152 [13, 17] 92153
1.11..11111111..... 368608 [14, 19] 368609
1.111111.1....1111.. 783420 [15, 20] 783421
1.111111.1....1111..... 6267360 [16, 23] 6267361
1.111111.1....1111...... 12534720 [17, 24] 12534721
1.111111.1.....111.1111111. 100273918 [18, 27] 100273919
1.11..11111111111111.1..11... 377487000 [19, 29] 377487001
1.11..11111111111111.1..11.... 754974000 [20, 30] 754974001
1.11..11111111111111.1..11...... 3019896000 [21, 32] 3019896001
1.11..11111.1..11111...1.11.1111... 24147626872 [22, 35] 24147626873
1.11..11111.1..11111...1.11.1111...1. 96590507490 [23, 37] 96590507491
1.11..111.1......11....11..1.111111111. 385744948222 [24, 39] 385744948223
1.11..111.1......11....11..1.1111111111. 771489896446 [25, 40] 771489896447
1.11..111.1......11....11..1.111111111111. 3085959585790 [26, 42] 3085959585791
1.11..111.1......11....11..1.1111111111111... 24687676686328 [27, 45] 24687676686329
1.111111.1....11111....111..11..1.11..11..11111. 210298272002878 [28, 48] 210298272002879
1.11..111.1......11....11..1.111111111111.1..1..1.. 1580011307924772 [29, 51] 1580011307924773
1.11..111.1......11....11..1.1111111111111...1.1.1111. 12640090463400286 [30, 54] 12640090463400287
1.111111.1....1111.......1111..11.1.1.11.11111..1..111. 26918107252899406 [31, 55] 26918107252899407

what is the asymptotic growth rate of the records?  it appears worse than O(2^n).

the later entries were calculated with a Haskell program doing branch-and-bound, which is much more efficient than brute force.  below is the key routine.  searching all binary numbers of a given bitwidth is equivalent to traversing a full binary tree of a given height.  because we are looking for records, we know what previous record we need to exceed.  when exploring a node in the middle of the tree, we know how many primes (or primes minus 1) we already have in the path back to the root.  the upper bound of the number of primes left, down to the leaf, is the height above the leaves.  these can be combined to yield an upper bound for the number of primes on this branch of the tree.  if the upper bound is less than the goal, we can prune, abandoning this branch (mzero).

binary numbers are represented as little-endian lists of Bool.  searching the False branch first searches smaller numbers first.  (future work: it's probably better to store the "path so far" as a bitstring.)

dosearch :: forall m . (MonadPlus m) => Integer -> ([Bool], Integer) -> Integer -> m[Bool];
dosearch goal (_, primessofar) numleft | primessofar+numleft < goal = Monad.mzero;
dosearch _ (pathsofar, _) 0 = return pathsofar;
dosearch goal (pathsofar, primessofar) numleft = let {
  nextodd :: [Bool] = True:pathsofar;
  nextprimesofar :: Integer = if isPrime $ binarytointeger nextodd
   then 1+primessofar
   else primessofar;
  nextsearch :: [Bool] -> m [Bool];
  nextsearch path = dosearch goal (path, nextprimesofar) (pred numleft);
} in nextsearch (False:pathsofar) `Monad.mplus` nextsearch nextodd;

(the infix application of mplus eliminates some parentheses.)

future work: parallelize, faster primality testing.

below is a list that includes numbers that tie (not necessarily exceed) the record number of primes.  these were found by brute force, so the list does not go as far as above.  the last number produces 21 primes.  no longer are all starting numbers prime or one less than a prime.

0 1 2 3 4 5 6 7 8 9 10 11 12 13 16 17 18 19 20 21 22 23 36 37 40 41 42 43 44 45 46 47 72 73 82 83 88 89 92 93 94 95 106 107 144 145 146 147 148 149 150 151 156 157 162 163 164 165 166 167 178 179 190 191 292 293 312 313 330 331 332 333 334 335 346 347 352 353 356 357 358 359 382 383 586 587 660 661 716 717 718 719 1320 1321 1432 1433 1436 1437 1438 1439 2876 2877 2878 2879 5756 5757 5758 5759 6120 6121 11278 11279 11496 11497 11512 11513 11514 11515 11516 11517 11518 11519 12240 12241 22992 22993 23026 23027 23028 23029 23036 23037 23038 23039 24480 24481 46072 46073 46076 46077 46078 46079 48960 48961 48962 48963 84718 84719 90238 90239 91968 91969 92040 92041 92106 92107 92110 92111 92118 92119 92144 92145 92146 92147 92152 92153 97926 97927 184080 184081 184290 184291 184304 184305 184306 184307 184308 184309 195852 195853 195854 195855 195862 195863 360946 360947 360952 360953 360958 360959 367878 367879 368160 368161 368162 368163 368398 368399 368442 368443 368446 368447 368578 368579 368580 368581 368582 368583 368608 368609 391710 391711 737158 737159 737216 737217 737218 737219 783412 783413 783420 783421 1474432 1474433 1474438 1474439 1566826 1566827 1566840 1566841 1566842 1566843 1566846 1566847 2943000 2943001 2948712 2948713 2948864 2948865 2948866 2948867 2948872 2948873 2948876 2948877 2948878 2948879 2949118 2949119 3133642 3133643 3133652 3133653 3133654 3133655 3133680 3133681 3133682 3133683 3133684 3133685 3133686 3133687 3133692 3133693 3133694 3133695 3136512 3136513 4864080 4864081 5775126 5775127 5775148 5775149 5775270 5775271 5775336 5775337 5886000 5886001 5886002 5886003 5886006 5886007 5890582 5890583 5890606 5890607 5895118 5895119 5895166 5895167 5895366 5895367 5895418 5895419 5897250 5897251 5897266 5897267 5897278 5897279 5897424 5897425 5897426 5897427 5897728 5897729 5897730 5897731 5897732 5897733 5897734 5897735 5897744 5897745 5897746 5897747 5897752 5897753 5897754 5897755 5897756 5897757 5897758 5897759 5897760 5897761 5897766 5897767 5897806 5897807 5897818 5897819 5897832 5897833 5897952 5897953 5898236 5898237 5898238 5898239 6237598 6237599 6259972 6259973 6266926 6266927 6267060 6267061 6267070 6267071 6267076 6267077 6267082 6267083 6267284 6267285 6267286 6267287 6267298 6267299 6267304 6267305 6267306 6267307 6267308 6267309 6267310 6267311 6267346 6267347 6267360 6267361 6267366 6267367 6267388 6267389 11550298 11550299 11550540 11550541 11781166 11781167 11795460 11795461 11795470 11795471 11795518 11795519 12534142 12534143 12534568 12534569 12534616 12534617 12534618 12534619 12534720 12534721 12534778 12534779 25068286 25068287 25069138 25069139 25069440 25069441 25069442 25069443 25069468 25069469 25069556 25069557 25069558 25069559 34214398 34214399 47124666 47124667 47124862 47124863 47161342 47161343 47178132 47178133 47178238 47178239 47181960 47181961 50136572 50136573 50136574 50136575 50136660 50136661 50136958 50136959 50138276 50138277 50138278 50138279 50138470 50138471 50138478 50138479 50138880 50138881 50138882 50138883 50138884 50138885 50138886 50138887 50138926 50138927 50138936 50138937 50138938 50138939 50139112 50139113 50139114 50139115 50139116 50139117 50139118 50139119 68428792 68428793 68428796 68428797 68428798 68428799 92402388 92402389 92404198 92404199 92404342 92404343 94176000 94176001 94176012 94176013 94176028 94176029 94176772 94176773 94176778 94176779 94249332 94249333 94249334 94249335 94249338 94249339 94249720 94249721 94249722 94249723 94249724 94249725 94249726 94249727 94321342 94321343 94322684 94322685 94322686 94322687 94325866 94325867 94326666 94326667 94326718 94326719 94356022 94356023 94356264 94356265 94356266 94356267 94356476 94356477 94356478 94356479 94356570 94356571 94358800 94358801 94358808 94358809 94358826 94358827 94363656 94363657 94363680 94363681 94363692 94363693 94363728 94363729 94363768 94363769 94363920 94363921 94363922 94363923 94364026 94364027 94365888 94365889 94365892 94365893 94371750 94371751 100273056 100273057 100273138 100273139 100273140 100273141 100273144 100273145 100273146 100273147 100273148 100273149 100273150 100273151 100273152 100273153 100273320 100273321 100273322 100273323 100273912 100273913 100273916 100273917 100273918 100273919 100277766 100277767 100277872 100277873 188353558 188353559 188727312 188727313 188727456 188727457 188731786 188731787 188743500 188743501 200546302 200546303 200546640 200546641 200547836 200547837 200547838 200547839 200553106 200553107 200553108 200553109 200555520 200555521 200555526 200555527 200555532 200555533 200555534 200555535 200555542 200555543 200555566 200555567 200555700 200555701 200555712 200555713 200555744 200555745 200555746 200555747 200555752 200555753 273715192 273715193 342841318 342841319 369616798 369616799 369617340 369617341 369621540 369621541 376704000 376704001 376704006 376704007 376707116 376707117 376707118 376707119 376707480 376707481 376997280 376997281 376997338 376997339 376997352 376997353 376998406 376998407 376998888 376998889 376998898 376998899 376998900 376998901 377289658 377289659 377303040 377303041 377303470 377303471 377303532 377303533 377306668 377306669 377425056 377425057 377425912 377425913 377426280 377426281 377454624 377454625 377454626 377454627 377454628 377454629 377454768 377454769 377454912 377454913 377454914 377454915 377454996 377454997 377455692 377455693 377456110 377456111 377463552 377463553 377463570 377463571 377463572 377463573 377463574 377463575 377487000 377487001 401111040 401111041 401111068 401111069 401111400 401111401 401111506 401111507 753408000 753408001 754613338 754613339 754850112 754850113 754851826 754851827 754852560 754852561 754909828 754909829 754927140 754927141 754974000 754974001 1509948000 1509948001 1509948002 1509948003 1604444220 1604444221 1604446026 1604446027 3013632406 3013632407 3018453358 3018453359 3019410240 3019410241 3019708566 3019708567 3019896000 3019896001 6036906718 6036906719 6039792000 6039792001 6039792002 6039792003 6039792006 6039792007 6417777072 6417777073 6417807238 6417807239 12073713072 12073713073 12073813436 12073813437 12073813438 12073813439 12077629236 12077629237 12078563326 12078563327 12078595558 12078595559 12078834268 12078834269 12079584000 12079584001 12079584002 12079584003 12079584004 12079584005 12079584006 12079584007 12079584012 12079584013 12079584014 12079584015 12079584016 12079584017 12079584028 12079584029 12079584046 12079584047 12079584052 12079584053 12834985258 12834985259 12835553760 12835553761 12835553770 12835553771 12835554144 12835554145 12835554146 12835554147 12835554232 12835554233 12835587846 12835587847 12835614476 12835614477 12835614478 12835614479

Friday, July 15, 2022

[pcljyxvx] infix notation decreases parentheses

in Haskell, binaryfunction (f x) (g y) can be rewritten f x `binaryfunction` g y , removing a layer of parentheses, because function application has precedence higher than any operator.

permitting arbitrary binary functions to be turned into infix operators helps avoid Lisp's Too Many Parentheses.  previously, praising the dollar-sign operator.

however, I don't use this backticks feature very frequently, because if the operands are more complicated than simple function application, then infix notation does not decrease parenthesization.  for example: binaryoperator (f $ g x) (p $ q y) == (f $ g x) `binaryoperator` (p $ q y)

previously on binary operators, and currying them.

Saturday, April 30, 2022

[ljxgdqve] makeRegexOpts example

we demonstrate how to use the functions makeRegex and makeRegexOpts using the regex-tdfa Haskell regular expression package.

the key point is, you cannot use =~ if you want to use these functions.  if you do, for example:

bad :: String -> Bool;
bad s = s =~ (makeRegex "[[:digit:]]");

you will get inscrutable error messages:

* Ambiguous type variable `source0' arising from a use of `=~' prevents the constraint `(RegexMaker Regex CompOption ExecOption source0)' from being solved.

* Ambiguous type variables `source0', `compOpt0', `execOpt0' arising from a use of `makeRegex' prevents the constraint `(RegexMaker source0 compOpt0 execOpt0 [Char])' from being solved.

instead, you have to use matchTest or similar functions described in Text.Regex.Base.RegexLike in regex-base.  the functions are reexported by but not documented in Text.Regex.TDFA .

https://gabebw.com/blog/2015/10/11/regular-expressions-in-haskell is a good explanation.

below is an example program that searches case-insensitively for input lines that contain the substring "gold", equivalent to "grep -i gold".  we need to use makeRegexOpts to disable case sensitivity.

module Main where {
import qualified Text.Regex.TDFA as Regex;

main :: IO();
main = getContents >>= ( mapM_ putStrLn . filter myregex . lines);

myregex :: String -> Bool;
myregex s = Regex.matchTest r s where {
  r :: Regex.Regex;
  r = Regex.makeRegexOpts mycompoptions myexecoptions "gold" ;
  mycompoptions :: Regex.CompOption;
  mycompoptions = Regex.defaultCompOpt {Regex.caseSensitive = False}; -- record syntax
  myexecoptions :: Regex.ExecOption;
  myexecoptions = Regex.defaultExecOpt;
};
}

here is documentation about all the available ExecOption and CompOption for this TDFA regex implementation.

previously, on the lack of substitution in Haskell regexes.

Thursday, April 07, 2022

[xcruhlyr] first-class pattern guards in Haskell

patterns are not first class objects in Haskell.  they cannot be assigned to variables nor passed around.

in the function f1 below, the patterns Apple and Banana are hardcoded.

data Fruit = Apple | Banana | Orange ;

f1 :: Fruit -> String;
f1 Apple = "got first choice fruit";
f1 Banana = "got second choice fruit";
f1 _ = "did not get what we want";

however, unlike patterns, pattern guards can be first-class objects.  using them, we can accomplish anything a first-class pattern could do.  in the example below, we pass patterns as boolean predicates to f2 and call them in the pattern guards (to the right of the vertical bar).  applep, bananap, and orangep are patterns turned into boolean functions.

f2 :: (Fruit -> Bool) -> (Fruit -> Bool) -> Fruit -> String;
f2 pattern1 pattern2 fruit
| pattern1 fruit = "got first choice fruit" -- note: no semicolon here
| pattern2 fruit = "got second choice fruit";
f2 _ _ _ = "did not get what we want";

applep :: Fruit -> Bool;
applep Apple = True;
applep _ = False;

bananap :: Fruit -> Bool;
bananap Banana = True;
bananap _ = False;

orangep :: Fruit -> Bool;
orangep Orange = True;
orangep _ = False;

examplef2 :: Fruit -> IO();
examplef2 fruit = do {
putStrLn $ f2 applep bananap fruit;
putStrLn $ f2 orangep applep fruit;
};

we can also do pattern matching, encapsulating extraction of a value from a pattern into a (first-class) function returning Maybe.  below, the function superhero calls its supplied pattern and attempts to match against Just.  if the pattern returns Nothing, the guard fails, and we fall through to "muggle".

data Health = Mind Int | Body Int;

superhero :: (Health -> Maybe Int) -> Health -> String;
superhero pattern health | Just power <- pattern health = if power > 9000
  then "is superhero"
  else "not strong enough";
superhero _ _ = "muggle";

getmind :: Health -> Maybe Int;
getmind (Mind i) = Just i;
getmind _ = Nothing;

getbody :: Health -> Maybe Int;
getbody (Body i) = Just i;
getbody _ = Nothing;

powermeter :: Health -> IO();
powermeter health = do {
putStrLn $ superhero getmind health;
putStrLn $ superhero getbody health;
};

in general, because what we pass is a function, we can build up a pattern guard in the myriad of ways we can build a function in a functional programming language.  however, I have not explored this very far.

a pattern guard can have several components, separated by commas.  a comma acts like the boolean AND operator.  each component can be a boolean expression, a pattern match (its boolean value is whether the match succeeds), or an assignment of a local variable with "let" (always evaluates to True).

note well: pattern matching in a guard is different from pattern matching in a let in a guard.  unlike the definition above, the following always succeeds, never falling through to "muggle".  if pattern returns Nothing, then a run-time error "Non-exhaustive patterns" occurs.

superhero pattern health | let { Just power = pattern health } = if power ...

Saturday, March 12, 2022

[eexymbii] color palettes

some widely separated points in the RGB color cube.  previously, the right way to do this, using the Cielab color space.

8 colors (cube vertices): rgb(0,0,0)=  , rgb(0,0,255)=  , rgb(0,255,0)=  , rgb(0,255,255)=  , rgb(255,0,0)=  , rgb(255,0,255)=  , rgb(255,255,0)=  , rgb(255,255,255)=  

9 colors (8 colors + gray): rgb(0,0,0)=  , rgb(0,0,255)=  , rgb(0,255,0)=  , rgb(0,255,255)=  , rgb(255,0,0)=  , rgb(255,0,255)=  , rgb(255,255,0)=  , rgb(255,255,255)=  , rgb(128,128,128)=  

12 colors (vertices + 3 gradations of green): rgb(0,0,0)=  , rgb(0,0,255)=  , rgb(0,128,0)=  , rgb(0,128,255)=  , rgb(0,255,0)=  , rgb(0,255,255)=  , rgb(255,0,0)=  , rgb(255,0,255)=  , rgb(255,128,0)=  , rgb(255,128,255)=  , rgb(255,255,0)=  , rgb(255,255,255)=  

13 colors (12 colors + gray): rgb(0,0,0)=  , rgb(0,0,255)=  , rgb(0,128,0)=  , rgb(0,128,255)=  , rgb(0,255,0)=  , rgb(0,255,255)=  , rgb(255,0,0)=  , rgb(255,0,255)=  , rgb(255,128,0)=  , rgb(255,128,255)=  , rgb(255,255,0)=  , rgb(255,255,255)=  , rgb(128,128,128)=  

18 colors (3 gradations of red, green): rgb(0,0,0)=  , rgb(0,0,255)=  , rgb(0,128,0)=  , rgb(0,128,255)=  , rgb(0,255,0)=  , rgb(0,255,255)=  , rgb(128,0,0)=  , rgb(128,0,255)=  , rgb(128,128,0)=  , rgb(128,128,255)=  , rgb(128,255,0)=  , rgb(128,255,255)=  , rgb(255,0,0)=  , rgb(255,0,255)=  , rgb(255,128,0)=  , rgb(255,128,255)=  , rgb(255,255,0)=  , rgb(255,255,255)=  

19 colors (18 colors + gray): rgb(0,0,0)=  , rgb(0,0,255)=  , rgb(0,128,0)=  , rgb(0,128,255)=  , rgb(0,255,0)=  , rgb(0,255,255)=  , rgb(128,0,0)=  , rgb(128,0,255)=  , rgb(128,128,0)=  , rgb(128,128,255)=  , rgb(128,255,0)=  , rgb(128,255,255)=  , rgb(255,0,0)=  , rgb(255,0,255)=  , rgb(255,128,0)=  , rgb(255,128,255)=  , rgb(255,255,0)=  , rgb(255,255,255)=  , rgb(128,128,128)=  

27 colors (3 gradations of all): rgb(0,0,0)=  , rgb(0,0,128)=  , rgb(0,0,255)=  , rgb(0,128,0)=  , rgb(0,128,128)=  , rgb(0,128,255)=  , rgb(0,255,0)=  , rgb(0,255,128)=  , rgb(0,255,255)=  , rgb(128,0,0)=  , rgb(128,0,128)=  , rgb(128,0,255)=  , rgb(128,128,0)=  , rgb(128,128,128)=  , rgb(128,128,255)=  , rgb(128,255,0)=  , rgb(128,255,128)=  , rgb(128,255,255)=  , rgb(255,0,0)=  , rgb(255,0,128)=  , rgb(255,0,255)=  , rgb(255,128,0)=  , rgb(255,128,128)=  , rgb(255,128,255)=  , rgb(255,255,0)=  , rgb(255,255,128)=  , rgb(255,255,255)=  

16 colors named in HTML 4.01: rgb(255,255,255)=  , rgb(192,192,192)=  , rgb(128,128,128)=  , rgb(0,0,0)=  , rgb(255,0,0)=  , rgb(128,0,0)=  , rgb(255,255,0)=  , rgb(128,128,0)=  , rgb(0,255,0)=  , rgb(0,128,0)=  , rgb(0,255,255)=  , rgb(0,128,128)=  , rgb(0,0,255)=  , rgb(0,0,128)=  , rgb(255,0,255)=  , rgb(128,0,128)=  

set difference of the 27-color set minus the 16-color set (12 colors not present in the 16-color set): rgb(0,128,255)=  , rgb(0,255,128)=  , rgb(128,0,255)=  , rgb(128,128,255)=  , rgb(128,255,0)=  , rgb(128,255,128)=  , rgb(128,255,255)=  , rgb(255,0,128)=  , rgb(255,128,0)=  , rgb(255,128,128)=  , rgb(255,128,255)=  , rgb(255,255,128)=  

instead of appending gray rgb(128,128,128) in the sets above, perhaps it would have been better to append the silver rgb(192,192,192) of HTML 4.01.

Haskell source code to generate HTML for this post.  we use list as the nondeterminism monad, "iterating" over ranges with Monad.replicateM and sequence:

range2 = [0,255];

range3 = [0,128,255];

set8 :: [Color];
set8 = Monad.replicateM 3 range2 & map Color;

set12 :: [Color];
set12 = [range2, range3, range2] & sequence & map Color;

Saturday, February 05, 2022

[vnhqmqp] Semiprimes

Below is a list of the first 1000 semiprimes, the product of two prime numbers, both approximately the same size.  The criterion we chose is that the larger factor must be less than twice the smaller factor.  In other words, both factors must have approximately the same number of bits.  This criterion, for much larger semiprimes, is good for RSA cryptography.

Tangentially, other less restrictive criteria we could have chosen but didn't:

  1. No restrictions on the relative sizes of the two prime factors.  Such a list would still exclude composites which have 3 or more prime factors.
  2. The larger factor must be less than the square of the smaller factor.  In other words, no more than twice the number of digits

Perfect squares are permitted on our list below.  (But they should not be permitted as RSA moduli.)

Previously, on rectangles that are squarish.

It might be fun to try to memorize the first few semiprimes and their factorizations, say, up to 1000 (the first 36). The brain unconsciously organizes things.

What is the growth rate of the sequence?  This is probably not difficult to derive from the Prime Number Theorem.

Here is some Haskell code to compute the list in order..  We use Data.List.Ordered.mergeAll from the ordered-list package.  Previously, on this handy package.

4 = 2 * 2
6 = 2 * 3
9 = 3 * 3
15 = 3 * 5
25 = 5 * 5
35 = 5 * 7
49 = 7 * 7
77 = 7 * 11
91 = 7 * 13
121 = 11 * 11
143 = 11 * 13
169 = 13 * 13
187 = 11 * 17
209 = 11 * 19
221 = 13 * 17
247 = 13 * 19
289 = 17 * 17
299 = 13 * 23
323 = 17 * 19
361 = 19 * 19
391 = 17 * 23
437 = 19 * 23
493 = 17 * 29
527 = 17 * 31
529 = 23 * 23
551 = 19 * 29
589 = 19 * 31
667 = 23 * 29
703 = 19 * 37
713 = 23 * 31
841 = 29 * 29
851 = 23 * 37
899 = 29 * 31
943 = 23 * 41
961 = 31 * 31
989 = 23 * 43
1073 = 29 * 37
1147 = 31 * 37
1189 = 29 * 41
1247 = 29 * 43
1271 = 31 * 41
1333 = 31 * 43
1363 = 29 * 47
1369 = 37 * 37
1457 = 31 * 47
1517 = 37 * 41
1537 = 29 * 53
1591 = 37 * 43
1643 = 31 * 53
1681 = 41 * 41
1739 = 37 * 47
1763 = 41 * 43
1829 = 31 * 59
1849 = 43 * 43
1891 = 31 * 61
1927 = 41 * 47
1961 = 37 * 53
2021 = 43 * 47
2173 = 41 * 53
2183 = 37 * 59
2209 = 47 * 47
2257 = 37 * 61
2279 = 43 * 53
2419 = 41 * 59
2479 = 37 * 67
2491 = 47 * 53
2501 = 41 * 61
2537 = 43 * 59
2623 = 43 * 61
2627 = 37 * 71
2701 = 37 * 73
2747 = 41 * 67
2773 = 47 * 59
2809 = 53 * 53
2867 = 47 * 61
2881 = 43 * 67
2911 = 41 * 71
2993 = 41 * 73
3053 = 43 * 71
3127 = 53 * 59
3139 = 43 * 73
3149 = 47 * 67
3233 = 53 * 61
3239 = 41 * 79
3337 = 47 * 71
3397 = 43 * 79
3431 = 47 * 73
3481 = 59 * 59
3551 = 53 * 67
3569 = 43 * 83
3599 = 59 * 61
3713 = 47 * 79
3721 = 61 * 61
3763 = 53 * 71
3869 = 53 * 73
3901 = 47 * 83
3953 = 59 * 67
4087 = 61 * 67
4183 = 47 * 89
4187 = 53 * 79
4189 = 59 * 71
4307 = 59 * 73
4331 = 61 * 71
4399 = 53 * 83
4453 = 61 * 73
4489 = 67 * 67
4661 = 59 * 79
4717 = 53 * 89
4757 = 67 * 71
4819 = 61 * 79
4891 = 67 * 73
4897 = 59 * 83
5041 = 71 * 71
5063 = 61 * 83
5141 = 53 * 97
5183 = 71 * 73
5251 = 59 * 89
5293 = 67 * 79
5329 = 73 * 73
5353 = 53 * 101
5429 = 61 * 89
5459 = 53 * 103
5561 = 67 * 83
5609 = 71 * 79
5723 = 59 * 97
5767 = 73 * 79
5893 = 71 * 83
5917 = 61 * 97
5959 = 59 * 101
5963 = 67 * 89
6059 = 73 * 83
6077 = 59 * 103
6161 = 61 * 101
6241 = 79 * 79
6283 = 61 * 103
6313 = 59 * 107
6319 = 71 * 89
6431 = 59 * 109
6497 = 73 * 89
6499 = 67 * 97
6527 = 61 * 107
6557 = 79 * 83
6649 = 61 * 109
6667 = 59 * 113
6767 = 67 * 101
6887 = 71 * 97
6889 = 83 * 83
6893 = 61 * 113
6901 = 67 * 103
7031 = 79 * 89
7081 = 73 * 97
7169 = 67 * 107
7171 = 71 * 101
7303 = 67 * 109
7313 = 71 * 103
7373 = 73 * 101
7387 = 83 * 89
7519 = 73 * 103
7571 = 67 * 113
7597 = 71 * 107
7663 = 79 * 97
7739 = 71 * 109
7811 = 73 * 107
7921 = 89 * 89
7957 = 73 * 109
7979 = 79 * 101
8023 = 71 * 113
8051 = 83 * 97
8137 = 79 * 103
8249 = 73 * 113
8383 = 83 * 101
8453 = 79 * 107
8509 = 67 * 127
8549 = 83 * 103
8611 = 79 * 109
8633 = 89 * 97
8777 = 67 * 131
8881 = 83 * 107
8927 = 79 * 113
8989 = 89 * 101
9017 = 71 * 127
9047 = 83 * 109
9167 = 89 * 103
9271 = 73 * 127
9301 = 71 * 131
9379 = 83 * 113
9409 = 97 * 97
9523 = 89 * 107
9563 = 73 * 131
9701 = 89 * 109
9727 = 71 * 137
9797 = 97 * 101
9869 = 71 * 139
9991 = 97 * 103
10001 = 73 * 137
10033 = 79 * 127
10057 = 89 * 113
10147 = 73 * 139
10201 = 101 * 101
10349 = 79 * 131
10379 = 97 * 107
10403 = 101 * 103
10541 = 83 * 127
10573 = 97 * 109
10609 = 103 * 103
10807 = 101 * 107
10823 = 79 * 137
10873 = 83 * 131
10961 = 97 * 113
10981 = 79 * 139
11009 = 101 * 109
11021 = 103 * 107
11227 = 103 * 109
11303 = 89 * 127
11371 = 83 * 137
11413 = 101 * 113
11449 = 107 * 107
11537 = 83 * 139
11639 = 103 * 113
11659 = 89 * 131
11663 = 107 * 109
11771 = 79 * 149
11881 = 109 * 109
11929 = 79 * 151
12091 = 107 * 113
12193 = 89 * 137
12317 = 109 * 113
12319 = 97 * 127
12367 = 83 * 149
12371 = 89 * 139
12403 = 79 * 157
12533 = 83 * 151
12707 = 97 * 131
12769 = 113 * 113
12827 = 101 * 127
13031 = 83 * 157
13081 = 103 * 127
13231 = 101 * 131
13261 = 89 * 149
13289 = 97 * 137
13439 = 89 * 151
13483 = 97 * 139
13493 = 103 * 131
13529 = 83 * 163
13589 = 107 * 127
13837 = 101 * 137
13843 = 109 * 127
13973 = 89 * 157
14017 = 107 * 131
14039 = 101 * 139
14111 = 103 * 137
14279 = 109 * 131
14317 = 103 * 139
14351 = 113 * 127
14453 = 97 * 149
14507 = 89 * 163
14647 = 97 * 151
14659 = 107 * 137
14803 = 113 * 131
14863 = 89 * 167
14873 = 107 * 139
14933 = 109 * 137
15049 = 101 * 149
15151 = 109 * 139
15229 = 97 * 157
15251 = 101 * 151
15347 = 103 * 149
15397 = 89 * 173
15481 = 113 * 137
15553 = 103 * 151
15707 = 113 * 139
15811 = 97 * 163
15857 = 101 * 157
15943 = 107 * 149
16129 = 127 * 127
16157 = 107 * 151
16171 = 103 * 157
16199 = 97 * 167
16241 = 109 * 149
16459 = 109 * 151
16463 = 101 * 163
16637 = 127 * 131
16781 = 97 * 173
16789 = 103 * 163
16799 = 107 * 157
16837 = 113 * 149
16867 = 101 * 167
17063 = 113 * 151
17113 = 109 * 157
17161 = 131 * 131
17201 = 103 * 167
17363 = 97 * 179
17399 = 127 * 137
17441 = 107 * 163
17473 = 101 * 173
17557 = 97 * 181
17653 = 127 * 139
17741 = 113 * 157
17767 = 109 * 163
17819 = 103 * 173
17869 = 107 * 167
17947 = 131 * 137
18079 = 101 * 179
18203 = 109 * 167
18209 = 131 * 139
18281 = 101 * 181
18419 = 113 * 163
18437 = 103 * 179
18511 = 107 * 173
18527 = 97 * 191
18643 = 103 * 181
18721 = 97 * 193
18769 = 137 * 137
18857 = 109 * 173
18871 = 113 * 167
18923 = 127 * 149
19043 = 137 * 139
19153 = 107 * 179
19177 = 127 * 151
19291 = 101 * 191
19321 = 139 * 139
19367 = 107 * 181
19493 = 101 * 193
19511 = 109 * 179
19519 = 131 * 149
19549 = 113 * 173
19673 = 103 * 191
19729 = 109 * 181
19781 = 131 * 151
19879 = 103 * 193
19897 = 101 * 197
19939 = 127 * 157
20099 = 101 * 199
20227 = 113 * 179
20291 = 103 * 197
20413 = 137 * 149
20437 = 107 * 191
20453 = 113 * 181
20497 = 103 * 199
20567 = 131 * 157
20651 = 107 * 193
20687 = 137 * 151
20701 = 127 * 163
20711 = 139 * 149
20819 = 109 * 191
20989 = 139 * 151
21037 = 109 * 193
21079 = 107 * 197
21209 = 127 * 167
21293 = 107 * 199
21353 = 131 * 163
21473 = 109 * 197
21509 = 137 * 157
21583 = 113 * 191
21691 = 109 * 199
21809 = 113 * 193
21823 = 139 * 157
21877 = 131 * 167
21971 = 127 * 173
22201 = 149 * 149
22261 = 113 * 197
22331 = 137 * 163
22487 = 113 * 199
22499 = 149 * 151
22577 = 107 * 211
22657 = 139 * 163
22663 = 131 * 173
22733 = 127 * 179
22801 = 151 * 151
22879 = 137 * 167
22987 = 127 * 181
22999 = 109 * 211
23213 = 139 * 167
23393 = 149 * 157
23449 = 131 * 179
23701 = 137 * 173
23707 = 151 * 157
23711 = 131 * 181
23843 = 113 * 211
24047 = 139 * 173
24257 = 127 * 191
24287 = 149 * 163
24511 = 127 * 193
24523 = 137 * 179
24613 = 151 * 163
24649 = 157 * 157
24797 = 137 * 181
24881 = 139 * 179
24883 = 149 * 167
25019 = 127 * 197
25021 = 131 * 191
25159 = 139 * 181
25199 = 113 * 223
25217 = 151 * 167
25273 = 127 * 199
25283 = 131 * 193
25591 = 157 * 163
25777 = 149 * 173
25807 = 131 * 197
26069 = 131 * 199
26123 = 151 * 173
26167 = 137 * 191
26219 = 157 * 167
26441 = 137 * 193
26549 = 139 * 191
26569 = 163 * 163
26671 = 149 * 179
26797 = 127 * 211
26827 = 139 * 193
26969 = 149 * 181
26989 = 137 * 197
27029 = 151 * 179
27161 = 157 * 173
27221 = 163 * 167
27263 = 137 * 199
27331 = 151 * 181
27383 = 139 * 197
27641 = 131 * 211
27661 = 139 * 199
27889 = 167 * 167
28103 = 157 * 179
28199 = 163 * 173
28321 = 127 * 223
28417 = 157 * 181
28459 = 149 * 191
28757 = 149 * 193
28829 = 127 * 227
28841 = 151 * 191
28891 = 167 * 173
28907 = 137 * 211
29083 = 127 * 229
29143 = 151 * 193
29177 = 163 * 179
29213 = 131 * 223
29329 = 139 * 211
29353 = 149 * 197
29503 = 163 * 181
29591 = 127 * 233
29651 = 149 * 199
29737 = 131 * 227
29747 = 151 * 197
29893 = 167 * 179
29929 = 173 * 173
29987 = 157 * 191
29999 = 131 * 229
30049 = 151 * 199
30227 = 167 * 181
30301 = 157 * 193
30353 = 127 * 239
30523 = 131 * 233
30551 = 137 * 223
30607 = 127 * 241
30929 = 157 * 197
30967 = 173 * 179
30997 = 139 * 223
31099 = 137 * 227
31133 = 163 * 191
31243 = 157 * 199
31309 = 131 * 239
31313 = 173 * 181
31373 = 137 * 229
31439 = 149 * 211
31459 = 163 * 193
31553 = 139 * 227
31571 = 131 * 241
31831 = 139 * 229
31861 = 151 * 211
31877 = 127 * 251
31897 = 167 * 191
31921 = 137 * 233
32041 = 179 * 179
32111 = 163 * 197
32231 = 167 * 193
32387 = 139 * 233
32399 = 179 * 181
32437 = 163 * 199
32743 = 137 * 239
32761 = 181 * 181
32881 = 131 * 251
32899 = 167 * 197
33017 = 137 * 241
33043 = 173 * 191
33127 = 157 * 211
33221 = 139 * 239
33227 = 149 * 223
33233 = 167 * 199
33389 = 173 * 193
33499 = 139 * 241
33667 = 131 * 257
33673 = 151 * 223
33823 = 149 * 227
34081 = 173 * 197
34121 = 149 * 229
34189 = 179 * 191
34277 = 151 * 227
34387 = 137 * 251
34393 = 163 * 211
34427 = 173 * 199
34547 = 179 * 193
34571 = 181 * 191
34579 = 151 * 229
34717 = 149 * 233
34889 = 139 * 251
34933 = 181 * 193
35011 = 157 * 223
35183 = 151 * 233
35209 = 137 * 257
35237 = 167 * 211
35263 = 179 * 197
35611 = 149 * 239
35621 = 179 * 199
35639 = 157 * 227
35657 = 181 * 197
35723 = 139 * 257
35909 = 149 * 241
35953 = 157 * 229
36019 = 181 * 199
36031 = 137 * 263
36089 = 151 * 239
36349 = 163 * 223
36391 = 151 * 241
36481 = 191 * 191
36503 = 173 * 211
36557 = 139 * 263
36581 = 157 * 233
36853 = 137 * 269
36863 = 191 * 193
37001 = 163 * 227
37127 = 137 * 271
37241 = 167 * 223
37249 = 193 * 193
37327 = 163 * 229
37391 = 139 * 269
37399 = 149 * 251
37523 = 157 * 239
37627 = 191 * 197
37669 = 139 * 271
37769 = 179 * 211
37837 = 157 * 241
37901 = 151 * 251
37909 = 167 * 227
37979 = 163 * 233
38009 = 191 * 199
38021 = 193 * 197
38191 = 181 * 211
38243 = 167 * 229
38293 = 149 * 257
38407 = 193 * 199
38503 = 139 * 277
38579 = 173 * 223
38807 = 151 * 257
38809 = 197 * 197
38911 = 167 * 233
38957 = 163 * 239
39187 = 149 * 263
39203 = 197 * 199
39271 = 173 * 227
39283 = 163 * 241
39407 = 157 * 251
39601 = 199 * 199
39617 = 173 * 229
39713 = 151 * 263
39913 = 167 * 239
39917 = 179 * 223
40081 = 149 * 269
40247 = 167 * 241
40301 = 191 * 211
40309 = 173 * 233
40349 = 157 * 257
40363 = 181 * 223
40379 = 149 * 271
40619 = 151 * 269
40633 = 179 * 227
40723 = 193 * 211
40913 = 163 * 251
40921 = 151 * 271
40991 = 179 * 229
41087 = 181 * 227
41273 = 149 * 277
41291 = 157 * 263
41347 = 173 * 239
41449 = 181 * 229
41567 = 197 * 211
41693 = 173 * 241
41707 = 179 * 233
41827 = 151 * 277
41869 = 149 * 281
41891 = 163 * 257
41917 = 167 * 251
41989 = 199 * 211
42167 = 149 * 283
42173 = 181 * 233
42233 = 157 * 269
42431 = 151 * 281
42547 = 157 * 271
42593 = 191 * 223
42733 = 151 * 283
42781 = 179 * 239
42869 = 163 * 263
42919 = 167 * 257
43039 = 193 * 223
43139 = 179 * 241
43259 = 181 * 239
43357 = 191 * 227
43423 = 173 * 251
43489 = 157 * 277
43621 = 181 * 241
43657 = 149 * 293
43739 = 191 * 229
43811 = 193 * 227
43847 = 163 * 269
43921 = 167 * 263
43931 = 197 * 223
44117 = 157 * 281
44173 = 163 * 271
44197 = 193 * 229
44243 = 151 * 293
44377 = 199 * 223
44431 = 157 * 283
44461 = 173 * 257
44503 = 191 * 233
44521 = 211 * 211
44719 = 197 * 227
44923 = 167 * 269
44929 = 179 * 251
44969 = 193 * 233
45113 = 197 * 229
45151 = 163 * 277
45173 = 199 * 227
45257 = 167 * 271
45431 = 181 * 251
45499 = 173 * 263
45571 = 199 * 229
45649 = 191 * 239
45803 = 163 * 281
45901 = 197 * 233
46001 = 157 * 293
46003 = 179 * 257
46031 = 191 * 241
46127 = 193 * 239
46129 = 163 * 283
46259 = 167 * 277
46367 = 199 * 233
46513 = 193 * 241
46517 = 181 * 257
46537 = 173 * 269
46883 = 173 * 271
46927 = 167 * 281
47053 = 211 * 223
47077 = 179 * 263
47083 = 197 * 239
47261 = 167 * 283
47477 = 197 * 241
47561 = 199 * 239
47603 = 181 * 263
47759 = 163 * 293
47897 = 211 * 227
47921 = 173 * 277
47941 = 191 * 251
47959 = 199 * 241
48151 = 179 * 269
48199 = 157 * 307
48319 = 211 * 229
48443 = 193 * 251
48509 = 179 * 271
48613 = 173 * 281
48689 = 181 * 269
48827 = 157 * 311
48931 = 167 * 293
48959 = 173 * 283
49051 = 181 * 271
49087 = 191 * 257
49141 = 157 * 313
49163 = 211 * 233
49447 = 197 * 251
49583 = 179 * 277
49601 = 193 * 257
49729 = 223 * 223
49949 = 199 * 251
50041 = 163 * 307
50137 = 181 * 277
50233 = 191 * 263
50299 = 179 * 281
50429 = 211 * 239
50621 = 223 * 227
50629 = 197 * 257
50657 = 179 * 283
50689 = 173 * 293
50693 = 163 * 311
50759 = 193 * 263
50851 = 211 * 241
50861 = 181 * 281
51019 = 163 * 313
51067 = 223 * 229
51143 = 199 * 257
51223 = 181 * 283
51269 = 167 * 307
51379 = 191 * 269
51529 = 227 * 227
51671 = 163 * 317
51761 = 191 * 271
51811 = 197 * 263
51917 = 193 * 269
51937 = 167 * 311
51959 = 223 * 233
51983 = 227 * 229
52271 = 167 * 313
52303 = 193 * 271
52337 = 199 * 263
52441 = 229 * 229
52447 = 179 * 293
52891 = 227 * 233
52907 = 191 * 277
52939 = 167 * 317
52961 = 211 * 251
52993 = 197 * 269
53033 = 181 * 293
53111 = 173 * 307
53297 = 223 * 239
53357 = 229 * 233
53387 = 197 * 271
53461 = 193 * 277
53531 = 199 * 269
53671 = 191 * 281
53743 = 223 * 241
53803 = 173 * 311
53929 = 199 * 271
54053 = 191 * 283
54149 = 173 * 313
54227 = 211 * 257
54233 = 193 * 281
54253 = 227 * 239
54289 = 233 * 233
54569 = 197 * 277
54619 = 193 * 283
54707 = 227 * 241
54731 = 229 * 239
54841 = 173 * 317
54953 = 179 * 307
55123 = 199 * 277
55189 = 229 * 241
55277 = 167 * 331
55357 = 197 * 281
55493 = 211 * 263
55567 = 181 * 307
55669 = 179 * 311
55687 = 233 * 239
55751 = 197 * 283
55919 = 199 * 281
55963 = 191 * 293
55973 = 223 * 251
56027 = 179 * 313
56153 = 233 * 241
56291 = 181 * 311
56317 = 199 * 283
56549 = 193 * 293
56653 = 181 * 313
56743 = 179 * 317
56759 = 211 * 269
56977 = 227 * 251
57121 = 239 * 239
57181 = 211 * 271
57263 = 173 * 331
57311 = 223 * 257
57377 = 181 * 317
57479 = 229 * 251
57599 = 239 * 241
57721 = 197 * 293
58081 = 241 * 241
58301 = 173 * 337
58307 = 199 * 293
58339 = 227 * 257
58447 = 211 * 277
58483 = 233 * 251
58637 = 191 * 307
58649 = 223 * 263
58853 = 229 * 257
59249 = 179 * 331
59251 = 193 * 307
59291 = 211 * 281
59401 = 191 * 311
59701 = 227 * 263
59713 = 211 * 283
59783 = 191 * 313
59881 = 233 * 257
59911 = 181 * 331
59987 = 223 * 269
59989 = 239 * 251
60023 = 193 * 311
60227 = 229 * 263
60323 = 179 * 337
60409 = 193 * 313
60433 = 223 * 271
60479 = 197 * 307
60491 = 241 * 251
60547 = 191 * 317
60997 = 181 * 337
61063 = 227 * 269
61093 = 199 * 307
61181 = 193 * 317
61267 = 197 * 311
61279 = 233 * 263
61423 = 239 * 257
61517 = 227 * 271
61601 = 229 * 269
61661 = 197 * 313
61771 = 223 * 277
61823 = 211 * 293
61889 = 199 * 311
61937 = 241 * 257
62059 = 229 * 271
62113 = 179 * 347
62287 = 199 * 313
62449 = 197 * 317
62471 = 179 * 349
62663 = 223 * 281
62677 = 233 * 269
62807 = 181 * 347
62857 = 239 * 263
62879 = 227 * 277
63001 = 251 * 251
63083 = 199 * 317
63109 = 223 * 283
63143 = 233 * 271
63169 = 181 * 349
63187 = 179 * 353
63221 = 191 * 331
63383 = 241 * 263
63433 = 229 * 277
63787 = 227 * 281
63883 = 193 * 331
63893 = 181 * 353
64241 = 227 * 283
64291 = 239 * 269
64349 = 229 * 281
64367 = 191 * 337
64507 = 251 * 257
64541 = 233 * 277
64769 = 239 * 271
64777 = 211 * 307
64807 = 229 * 283
64829 = 241 * 269
64979 = 181 * 359
65041 = 193 * 337
65207 = 197 * 331
65311 = 241 * 271
65339 = 223 * 293
65473 = 233 * 281
65621 = 211 * 311
65869 = 199 * 331
65939 = 233 * 283
66013 = 251 * 263
66043 = 211 * 313
66049 = 257 * 257
66203 = 239 * 277
66277 = 191 * 347
66389 = 197 * 337
66511 = 227 * 293
66659 = 191 * 349
66757 = 241 * 277
66887 = 211 * 317
66971 = 193 * 347
67063 = 199 * 337
67097 = 229 * 293
67159 = 239 * 281
67357 = 193 * 349
67423 = 191 * 353
67519 = 251 * 269
67591 = 257 * 263
67637 = 239 * 283
67721 = 241 * 281
68021 = 251 * 271
68129 = 193 * 353
68203 = 241 * 283
68269 = 233 * 293
68359 = 197 * 347
68461 = 223 * 307
68569 = 191 * 359
68753 = 197 * 349
69053 = 199 * 347
69133 = 257 * 269
69169 = 263 * 263
69287 = 193 * 359
69353 = 223 * 311
69451 = 199 * 349
69527 = 251 * 277
69541 = 197 * 353
69647 = 257 * 271
69689 = 227 * 307
69799 = 223 * 313
69841 = 211 * 331
70027 = 239 * 293
70097 = 191 * 367
70247 = 199 * 353
70303 = 229 * 307
70531 = 251 * 281
70597 = 227 * 311
70613 = 241 * 293
70691 = 223 * 317
70723 = 197 * 359
70747 = 263 * 269
70831 = 193 * 367
71033 = 251 * 283
71051 = 227 * 313
71107 = 211 * 337
71189 = 257 * 277
71219 = 229 * 311
71243 = 191 * 373
71273 = 263 * 271
71441 = 199 * 359
71531 = 233 * 307
71677 = 229 * 313
71959 = 227 * 317
71989 = 193 * 373
72217 = 257 * 281
72299 = 197 * 367
72361 = 269 * 269
72389 = 191 * 379
72463 = 233 * 311
72593 = 229 * 317
72731 = 257 * 283
72851 = 263 * 277
72899 = 269 * 271
72929 = 233 * 313
73033 = 199 * 367
73147 = 193 * 379
73217 = 211 * 347
73373 = 239 * 307
73441 = 271 * 271
73481 = 197 * 373
73543 = 251 * 293
73639 = 211 * 349
73813 = 223 * 331
73861 = 233 * 317
73903 = 263 * 281
73919 = 193 * 383
73987 = 241 * 307
74227 = 199 * 373
74329 = 239 * 311
74429 = 263 * 283
74483 = 211 * 353
74513 = 269 * 277
74663 = 197 * 379
74807 = 239 * 313
74951 = 241 * 311
75067 = 271 * 277
75137 = 227 * 331
75151 = 223 * 337
75301 = 257 * 293
75421 = 199 * 379
75433 = 241 * 313
75451 = 197 * 383
75589 = 269 * 281
75749 = 211 * 359
75763 = 239 * 317
75799 = 229 * 331
76127 = 269 * 283
76151 = 271 * 281
76217 = 199 * 383
76397 = 241 * 317
76499 = 227 * 337
76633 = 197 * 389
76693 = 271 * 283
76729 = 277 * 277
77057 = 251 * 307
77059 = 263 * 293
77123 = 233 * 331
77173 = 229 * 337
77381 = 223 * 347
77411 = 199 * 389
77437 = 211 * 367
77827 = 223 * 349
77837 = 277 * 281
78061 = 251 * 311
78391 = 277 * 283
78521 = 233 * 337
78563 = 251 * 313
78703 = 211 * 373
78719 = 223 * 353
78769 = 227 * 347
78817 = 269 * 293
78899 = 257 * 307
78961 = 281 * 281
79003 = 199 * 397
79109 = 239 * 331
79223 = 227 * 349
79403 = 271 * 293
79463 = 229 * 347
79523 = 281 * 283
79567 = 251 * 317
79771 = 241 * 331
79921 = 229 * 349
79927 = 257 * 311
79969 = 211 * 379
80057 = 223 * 359
80089 = 283 * 283
80131 = 227 * 353
80441 = 257 * 313
80543 = 239 * 337
80741 = 263 * 307