HocusLocus7 hours ago
Like 'even and odd' on steroids.
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/A035313
Could you elaborate on your reasons for calling Eric Weisstein insane?
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.