@@ -38,6 +38,8 @@ <h2>Editor</h2>
3838plot(x => ceil(x / ln(x)));
3939plot(x => floor(li(x)));
4040plot(x => ceil(x / ln(x) + x / pow(ln(x), 2)));
41+ maybeprimes = maybePrimes(200000, []);
42+ plot(x => pix(x, maybeprimes));
4143
4244//plot(x => cgamma(complex(0, x)).y);
4345
@@ -392,6 +394,36 @@ <h2>Editor</h2>
392394 return num ;
393395}
394396
397+ const SEED = Math . random ( ) ;
398+ function rand ( n ) {
399+ let x = ( n * 374761393 + SEED * 668265263 ) >>> 0 ;
400+ x = ( ( x ^ ( x >>> 13 ) ) * 1274126177 ) >>> 0 ;
401+ x = ( x ^ ( x >>> 16 ) ) >>> 0 ;
402+ return x / 4294967296 ;
403+ }
404+
405+ function isMaybePrime ( n , primes = [ 2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 , 41 ] ) {
406+ const num = Math . ceil ( Math . abs ( n ) ) ;
407+ if ( num <= 1 ) return false ;
408+ if ( primes . includes ( num ) ) return true ;
409+ for ( const prime of primes ) {
410+ if ( num % prime === 0 ) return false ;
411+ }
412+ let W = 1 ;
413+ for ( const prime of primes ) {
414+ W *= ( 1 - 1 / prime ) ;
415+ }
416+ return rand ( n ) < 1 / Math . log ( num ) / W ;
417+ }
418+
419+ function maybePrimes ( n , primes = [ 2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 , 41 ] ) {
420+ let arr = [ ] ;
421+ for ( let i = 0 ; i < n ; i ++ ) {
422+ if ( isMaybePrime ( i , primes ) ) { arr . push ( i ) }
423+ }
424+ return arr ;
425+ }
426+
395427function pix ( x , primes ) {
396428 let left = 0 ;
397429 let right = primes . length - 1 ;
0 commit comments