A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Let f(a) be a function defined over the natural numbers. | |||||||||||||||||||||||||
2 | ||||||||||||||||||||||||||
3 | Suppose there exists one or more solutions "n" such that f(a) = n for many different a. Let's call the solution set A | |||||||||||||||||||||||||
4 | For such n, suppose we are interested in finding consecutive numbers x through x + k (k > 0) such that f(x+i) = n for every 0 <= i <= k | |||||||||||||||||||||||||
5 | ||||||||||||||||||||||||||
6 | Let L = k + 1, the range length | |||||||||||||||||||||||||
7 | Let the solutions x be partitioned into number of groups based on the range length. The set of groups is given by: product (p(i) ^ e(j) for j = 0 to ceiling (log(l)/log(p(i))) where each p is prime | |||||||||||||||||||||||||
8 | We partition the solutions into these groups so that we can later efficiently iterate over them (for the sake finding valid solutions in a consecutive range. | |||||||||||||||||||||||||
9 | Primes p > l are not in consideration in this exercise. This is a crude "first-pass" measure just to see what common solutions over a consecutive range would have to obey. | |||||||||||||||||||||||||
10 | ||||||||||||||||||||||||||
11 | Background: This general question came about when I unsuccessfully tried to tackle the problem posed here: https://www.primepuzzles.net/puzzles/puzz_670.htm | |||||||||||||||||||||||||
12 | ||||||||||||||||||||||||||
13 | Task: Compute S(L), the exact number of sets for each L >=1. Solutions have been computed through L = 19 using a C++ program. Currently, it stores the sets in an "unordered map". The code takes advantage of | |||||||||||||||||||||||||
14 | symmetry to avoid obvious redundancies but this quasi-brute force approach in the code requires progressively larger amounts of memory.. Ideally, a formula could be determined. | |||||||||||||||||||||||||
15 | Short of that, a program / heuristic that avoided storing large numbers of sets would be terrific. | |||||||||||||||||||||||||
16 | ||||||||||||||||||||||||||
17 | C++ Source: | https://github.com/grandpascorpion/miscMath | ||||||||||||||||||||||||
18 | ||||||||||||||||||||||||||
19 | ||||||||||||||||||||||||||
20 | L = 2 | |||||||||||||||||||||||||
21 | ||||||||||||||||||||||||||
22 | We only need to partition A into A(2) and A(1). In this context, A(2) means its members are divisible by any positive power of 2 (even) and A(1) means its members are all 2-unsmooth or odd. | |||||||||||||||||||||||||
23 | We only have two sensible combinations for solutions to f(x) = f(x+1) = n | |||||||||||||||||||||||||
24 | ||||||||||||||||||||||||||
25 | x | x+1 | ||||||||||||||||||||||||
26 | Member of A(2) | Member of A(1) | Even followed by odd | |||||||||||||||||||||||
27 | Member of A(1) | Member of A(2) | Odd followed by even | |||||||||||||||||||||||
28 | ||||||||||||||||||||||||||
29 | So, there are two classes of solutions for two consecutive numbers. | |||||||||||||||||||||||||
30 | Let's write this in shorthand as tuples (2,1) and (1,2) | |||||||||||||||||||||||||
31 | As we extend this to longer ranges, it's straightforward to compute the number of solution classes but I am interested in the number of sets. | |||||||||||||||||||||||||
32 | For length two, there is only one unique combination. Let's establish a convention that they are sorted from low to high by subscript. | |||||||||||||||||||||||||
33 | So, the lone "set" is (Member of A(1), Member of A(2)) or (1,2) for brevity | |||||||||||||||||||||||||
34 | ||||||||||||||||||||||||||
35 | ||||||||||||||||||||||||||
36 | L = 3 | |||||||||||||||||||||||||
37 | ||||||||||||||||||||||||||
38 | Note: That among 3 consecutive integers, at least one must be divisble by 3. We must partition A into two subsets: non-multiples and multiples of 3. Let's call these A'(3,1) and A'(3,3). | |||||||||||||||||||||||||
39 | If the first number of the 3-reange, "x" is 2 mod 4 then x +2 must be a multiple of 4. So, with respect to powers of 2, we need to partition A into 3 sets: | |||||||||||||||||||||||||
40 | 2-unsmooth, mod 4 = 2 and mod 4 = 0 (which is why the ceiling function was used earlier). | |||||||||||||||||||||||||
41 | ||||||||||||||||||||||||||
42 | We will call these subsets A'(2,1), A'(2,2), A'(2,4) | |||||||||||||||||||||||||
43 | We use A' instead of A because these are intermediate sets. We want to further partition A with respect to divisibility by both 2 and 3. | |||||||||||||||||||||||||
44 | If take the intersections of between the A'(2,_) and A'(3,_) sets, we have 3 * 2 = 6. We will label A(ij) = intersection of A'(2,i) and A'(3,j) | |||||||||||||||||||||||||
45 | This gives us A(1), A(2), A(3), A(4), A(6), A(12). | |||||||||||||||||||||||||
46 | Let's look at the possible valid combinations for powers of 2 and 3 and let's say mA'(x,y) means member of the set A'(x,y) | |||||||||||||||||||||||||
47 | ||||||||||||||||||||||||||
48 | x | x + 1 | x +2 | x | x + 1 | x +2 | ||||||||||||||||||||
49 | mA'(2,4) | mA'(2,1) | mA'(2,2) | mA'(3,3) | mA'(3,1) | mA'(3,1) | ||||||||||||||||||||
50 | mA'(2,1) | mA'(2,4) | mA'(2,1) | mA'(3,1) | mA'(3,3) | mA'(3,1) | ||||||||||||||||||||
51 | mA'(2,2) | mA'(2,1) | mA'(2,4) | mA'(3,1) | mA'(3,1) | mA'(3,3) | ||||||||||||||||||||
52 | mA'(2,1) | mA'(2,2) | mA'(2,1) | |||||||||||||||||||||||
53 | ||||||||||||||||||||||||||
54 | The notation above is a little cumbersome. Let's replace the entries with 2nd subscript and use that convention going forward and also indicate if they are symmetric and has a previously occurring mirror/inverse. | |||||||||||||||||||||||||
55 | ||||||||||||||||||||||||||
56 | x | x + 1 | x + 2 | Status* | x | x + 1 | x + 2 | Status* | ||||||||||||||||||
57 | 4 | 1 | 2 | N | 3 | 1 | 1 | N | ||||||||||||||||||
58 | 1 | 4 | 1 | S | 1 | 3 | 1 | S | ||||||||||||||||||
59 | 2 | 1 | 4 | Y | 1 | 1 | 3 | Y | ||||||||||||||||||
60 | 1 | 2 | 1 | S | ||||||||||||||||||||||
61 | ||||||||||||||||||||||||||
62 | * The status is defined as either: (S)ymmetrical, Y - previous mirror processed, N - previous mirror not processed | |||||||||||||||||||||||||
63 | ||||||||||||||||||||||||||
64 | If we take the cartesian product, we will get 4 * 3 = 12 solution classes | Cross-products | ||||||||||||||||||||||||
65 | ||||||||||||||||||||||||||
66 | x | x + 1 | x + 2 | x | x + 1 | x + 2 | x | x + 1 | x + 2 | |||||||||||||||||
67 | 4 | 1 | 2 | 3 | 1 | 1 | 12 | 1 | 2 | |||||||||||||||||
68 | 1 | 4 | 1 | 1 | 3 | 1 | 1 | 12 | 1 | |||||||||||||||||
69 | 2 | 1 | 4 | 1 | 1 | 3 | 2 | 1 | 12 | |||||||||||||||||
70 | 1 | 2 | 1 | 3 | 1 | 1 | 3 | 2 | 1 | |||||||||||||||||
71 | 4 | 1 | 2 | 1 | 3 | 1 | => | 4 | 3 | 2 | ||||||||||||||||
72 | 1 | 4 | 1 | 1 | 1 | 3 | 1 | 4 | 3 | |||||||||||||||||
73 | 2 | 1 | 4 | 3 | 1 | 1 | 6 | 1 | 4 | |||||||||||||||||
74 | 1 | 2 | 1 | 1 | 3 | 1 | 1 | 6 | 1 | |||||||||||||||||
75 | 4 | 1 | 2 | 1 | 1 | 3 | 4 | 1 | 6 | |||||||||||||||||
76 | 1 | 4 | 1 | 3 | 1 | 1 | 3 | 4 | 1 | |||||||||||||||||
77 | 2 | 1 | 4 | 1 | 3 | 1 | 2 | 3 | 4 | |||||||||||||||||
78 | 1 | 2 | 1 | 1 | 1 | 3 | 1 | 2 | 3 | |||||||||||||||||
79 | ||||||||||||||||||||||||||
80 | We are interested in the number of distinct sets. Now, we have to start considering symmetry and reflection. | |||||||||||||||||||||||||
81 | This is a reordering of the tables above to get a better handle on how symmetry/reflection of the specific power tuples factor in our calculation | |||||||||||||||||||||||||
82 | ||||||||||||||||||||||||||
83 | x | x + 1 | x + 2 | x | x + 1 | x + 2 | x | x + 1 | x + 2 | |||||||||||||||||
84 | 4 | 1 | 2 | 3 | 1 | 1 | 12 | 1 | 2 | New set (1,2,12) | ||||||||||||||||
85 | 4 | 1 | 2 | 1 | 1 | 3 | 4 | 1 | 6 | New set (1, 4, 6) | ||||||||||||||||
86 | 4 | 1 | 2 | 1 | 3 | 1 | 4 | 3 | 2 | New set (2, 3, 4) | ||||||||||||||||
87 | 2 | 1 | 4 | 3 | 1 | 1 | 6 | 1 | 4 | Redundant | ||||||||||||||||
88 | 2 | 1 | 4 | 1 | 1 | 3 | => | 2 | 1 | 12 | Redundant | |||||||||||||||
89 | 2 | 1 | 4 | 1 | 3 | 1 | 2 | 3 | 4 | Redundant | ||||||||||||||||
90 | 1 | 4 | 1 | 3 | 1 | 1 | 3 | 4 | 1 | New set (1, 3, 4) | ||||||||||||||||
91 | 1 | 4 | 1 | 1 | 1 | 3 | 1 | 4 | 3 | Redundant | ||||||||||||||||
92 | 1 | 4 | 1 | 1 | 3 | 1 | 1 | 12 | 1 | New set (1, 1, 12) | ||||||||||||||||
93 | 1 | 2 | 1 | 3 | 1 | 1 | 3 | 2 | 1 | New set (1,2, 3) | ||||||||||||||||
94 | 1 | 2 | 1 | 1 | 1 | 3 | 1 | 2 | 3 | Redundant | ||||||||||||||||
95 | 1 | 2 | 1 | 1 | 3 | 1 | 1 | 6 | 1 | New set (1, 1, 6) | ||||||||||||||||
96 | 7 unique sets in all | |||||||||||||||||||||||||
97 | Insights: | |||||||||||||||||||||||||
98 | (2,1,4) is the mirror image of (4,1,2) so it cannot contrubute any new sets. (4,1,2) has already contributed them. | |||||||||||||||||||||||||
99 | (1,4,1) and (1,2,1)'s behavior with respect to contributing new sets is the same (because they are symmetrical). | |||||||||||||||||||||||||
100 | As (1,4,1) is symmetrical, when combined with (3,1,1) and (1,1,3) there will only be one new set contributed from those two cross-products. |