Difference between revisions of "ZCubes/How to Apply Prime Numbers Twins, Cousins, Sexy Primes"

From ZCubes Wiki
Jump to navigation Jump to search
Line 20: Line 20:
 
         )
 
         )
  
2.gap=4
+
gap=4
PRIMES(100)//0)
+
PRIMES(100)//0)
 
     .filter(
 
     .filter(
 
         (x,i,d)=>
 
         (x,i,d)=>
Line 30: Line 30:
 
       .$(x=>[x-gap,x])   
 
       .$(x=>[x-gap,x])   
  
3.function primeswithgap(gap,till)
+
  function primeswithgap(gap,till)
 
{
 
{
 
     till=till||100;
 
     till=till||100;
Line 43: Line 43:
 
       return([ret ~])
 
       return([ret ~])
 
               }
 
               }
[2..10..2,100]@primeswithgap
+
 
[2..10..2,1000]@primeswithgap
+
[2..10..2,100]@primeswithgap
res=[2..30..2,1000]@primeswithgap;
+
[2..10..2,1000]@primeswithgap
res[3]
+
res=[2..30..2,1000]@primeswithgap;
 +
res[3]
  
  

Revision as of 05:12, 11 March 2020

How to Apply Prime Numbers Twins, 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]



<< Learn ZCubes
© Copyright 1996-2020, ZCubes, Inc.