Hi all,
An interesting method of determing non prime numbers (based on Dirichlet's theorem ).
It is based on coprimes and I read on a website the modulo 30 group is the one with the highest number that can do this.
I think this is not correct , the 210 modulo , 2310 etc ... will also do
(someone can predict the next "wheel"
-- it's not so difficult
(previous wheel is 30 , you c the trick
? )
As you can see the primes are located on rays , and more important the grey rays can NOT contain primes -- this algorithm is extreme fast determing a non prime (and in this case predicting an around 40% chance for a prime -- the red dots are the primes ) -- this of course lowers the bigger the numbers are (you can use the Li(x) function to find out how much )
it's written in NewLISP (a scripting language)
----------------------
(define dll "screen.dll")
(dolist (i '("setscreen" "scr" "pixel")) (import dll i))
(silent
(define mx (array 200000 '(0)))
(define ray-freq (array 210 2 '(0 0)))
(define pi (mul 2 (acos 0)))
(define (make-primes)
(dotimes (i 200000)
(when (= 1 (length (factor i))) (setf (mx i) 1))))
(define (polar x)
(let ((pos (mod x 210))
(ring (int (div x 209))))
(list (mul pos 12 (div 7)) (+ 90 ring) pos )))
(define (main n)
(make-primes)
(setscreen 800 800 200 20)
(dotimes (i n)
(letn ((L (polar i))
(hk (div (mul pi (L 0)) 180))
(x (int (mul (L 1) (cos hk))))
(y (int (mul (L 1) (sin hk)))))
(if (zero? (mx i))
(begin (pixel (+ 400 x) (+ 400 y) 88 88 88)
(++ ((ray-freq (L 2)) 0)))
(begin
(pixel (+ 400 x) (+ 400 y) 222 0 0)
(++ ((ray-freq (L 2)) 1)))))))
(define (report)
(dotimes (i 210)
(let ((result (ray-freq i)))
(print "Ray #" i " : ")
(print "Total hits : " (+ (result 0) (result 1)) " Prime hits : " (result 1))
(print " -> ="(int (mul 100 (div (result 1) (+ (result 0) (result 1))))) "%")
(println ""))))
)
(main 80000)
(report)
(println "")
(println "Enter to exit")
(read-char)
(scr 0)
(exit)
-----
and a dll doing the 2D output (from Freebasic)
question : is there an easy way (via dll ) to position the consolewindow -- newLISP lacks any control doing it -- been looking but only found something in C (using the studio.h ...
thanks in advance
rob
.