Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,28 @@
|
|||
ClearAll[NextInSequence, EKGSequence]
|
||||
NextInSequence[seq_List] := Module[{last, new = 1, holes, max, sel, found, i},
|
||||
last = Last[seq];
|
||||
max = Max[seq];
|
||||
holes = Complement[Range[max], seq];
|
||||
sel = SelectFirst[holes, Not[CoprimeQ[last, #]] &];
|
||||
If[MissingQ[sel],
|
||||
i = max;
|
||||
found = False;
|
||||
While[! found,
|
||||
i++;
|
||||
If[Not[CoprimeQ[last, i]],
|
||||
found = True
|
||||
]
|
||||
];
|
||||
Append[seq, i]
|
||||
,
|
||||
Append[seq, sel]
|
||||
]
|
||||
]
|
||||
EKGSequence[start_Integer, n_] := Nest[NextInSequence, {1, start}, n - 2]
|
||||
|
||||
Table[EKGSequence[s, 10], {s, {2, 5, 7, 9, 10}}] // Grid
|
||||
|
||||
s = Reverse[Transpose[{EKGSequence[5, 1000], EKGSequence[7, 1000]}]];
|
||||
len = LengthWhile[s, Apply[Equal]];
|
||||
s //= Reverse[Drop[#, len]] &;
|
||||
Length[s] + 1
|
||||
Loading…
Add table
Add a link
Reference in a new issue