Name: Anonymous 2015-09-27 2:25
So I have this program which searches to find out how many factors of a certain number there are in each one of them, then filters the ones below a certain value. For example, getting the count of 2-factors in first hundred natural numbers and remove all the 0s is
Here's a generator:
(1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2)
, while removing less than 1s is (2 3 2 4 2 3 2 5 2 3 2 4 2 3 2 6 2 3 2 4 2 3 2 5 2)
. It's obvious that this has a recursive structure (post-order traversal of a tree where all the nodes at height n have the value n), and that the number only increments on the powers of 2, etc, for whatever level of recursion that is being examined. Anyway, I thought that there might be something on the internet, but I didn't find any except some shit about unavoidable patterns, not factors. But the 2 sequence at least has something. 3's sequence is (1 1 2 1 1 2 1 1 3 1 1 2 1 1 2 1 1 3 1 1 2 1 1 2 1 1 4 1 1 2 1 1 2 1 1 3 1 1 2 1 1 2 1 1 3 1 1 2 1 1 2 1 1 4 1 1 2 1 1 2 1 1 3 1 1 2 ...)
at a threshold of 1, and (2 2 3 2 2 3 2 2 4 2 2 3 2 2 3 2 2 4 2 2 3 2 2 3 2 2 5 2 2 3 2 2 3 2 2 4 2 2 3 2 2 3 2 2 ...)
at a threshold of 2, .... It, and all the higher primes that I've looked at, have the same pattern. But I've found nothing on this pattern for 3, much less the greater primes. Should I be searching for something different to find information on these sequences?Here's a generator:
(define gen-pattern (lambda (magic searchmax thresh)
(letrec ((exact-int? (lambda (x) (and (integer? x) (exact? x))))
(f-count (lambda (x y)
(if (or (< y 2) (not (exact-int? (/ x y) ))) 0
(if (< x y) 1 (+ (f-count (/ x y) y) 1)))))
(search (lambda (i res) (if (> i searchmax) '() (cons (f-count i magic) (search (+ i 1) res)))))
(filt (lambda (pred li)
(if (null? li) '()
(if (pred (car li)) (cons (car li) (filt pred (cdr li))) (filt pred (cdr li)))))))
(filt (lambda (x) (not (< x thresh))) (search 1 '())))))