ZCubes/How to Apply Prime Numbers Twins, Cousins, Sexy Primes

From ZCubes Wiki
Jump to navigation Jump to search

Prime Numbers, Twin Primes, Cousins, Sexy Primes


This video demonstrates the computations of special prime numbers using ZCubes. Twin primes are prime numbers separated by two. Cousin primes are prime numbers separated by 4 and sexy primes are separated by six. Using ZCubes you can generate these primes or create functions to generate prime numbers with any gap. You can then do further analysis,

Video


Prime Numbers Twins, Cousins, Sexy Primes














Code

PRIMES(100)
 .map(
     (x,i,d)=>
         [
           i
           d[i],
           d.slice(0,i),
            (i>0?d[i]|-|d.slice(0,i):[])
          ]
       )
gap=4
PRIMES(100)//0)
    .filter(
        (x,i,d)=>
           (i>0?d[i]|-|d.slice(0,i):[])
               .include(gap)
            )
     .$(x=>[x-gap,x])  
 function primeswithgap(gap,till)
{
    till=till||100;
    var  ret=
         PRIMES(till)//0)
    .filter(
       (x,i,d)=>
       ((i>0?(d[i]|-|d.slice(0,i):[])
         .include(gap))
     )
    .$(x=>x-gap,x)
     return([ret ~])
             }
[2..10..2,100]@primeswithgap
[2..10..2,1000]@primeswithgap
res=[2..30..2,1000]@primeswithgap;
res[3]






© Copyright 1996-2020, ZCubes, Inc.