boolean isInSequence(n):
that decides whether the given integer is part of that sequence or not. However, pre-storing the sequence and only performing a lookup is not allowed. rec ((x:xs),p) = (filter (/= p+x) xs,p+x)
sequ = map snd $ iterate rec ([2..],1)
sequ is an infinite list of terms of the sequence A005228.By the way, the use of `filter` makes your implementation unnecessarily slow. (The posted link also contains Haskell code, which uses `delete` from Data.List instead of `filter`, which is only slightly better.)
I'd solve it like this, which generates both sequences in O(n) time, and the mutual recursion is cute:
a005228 = 1 : zipWith (+) a005228 a030124
a030124 = go 1 a005228 where
go x ys
| x < head ys = x : go (x + 1) ys
| otherwise = x + 1 : go (x + 2) (tail ys)If you think about it, it quantifies emergence of harmonic interference in the superposition of 4 distinct waveforms. If those waveforms happen to have irrational wavelengths (wrt. each other), their combination will never be in the same state twice.
This obviously has implications for pseudorandomness, etc.
Something like
1 3 9 26 66
2 6 17 40
4 11 23
7 12
5
Oh, here it is: https://oeis.org/A035313That sequence is not known to match what you asked for:
>> Conjecturally, every positive integer occurs in the sequence or one of its n-th differences, which would imply that the sequence and its n-th differences partition the positive integers.
For an intuition of why this might be hard to prove, note that you had to insert 7 into your structure before you inserted 5. In the general case, there might be a long waiting period before you're able to place some particular integer n. It might be infinitely long.
From my (limited) experience the OEIS titles lean strongly to the descriptive side too. But maybe also to avoid ambiguity regarding to which one is it from his sequences?
8organicbits•7mo ago
nurettin•7mo ago
volemo•7mo ago
Could you elaborate on your reasons for calling Eric Weisstein insane?
Rexxar•7mo ago
nurettin•7mo ago
foodevl•7mo ago
quietbritishjim•7mo ago
lutusp•7mo ago
I assume you're referring to Stephen Wolfram, not Neil Sloane, but it seems many people would like clarification.
As to Wolfram, assuming this is your focus, nothing undermines one's sanity as reliably as complete success. Not to accept your premise, only to explain it.