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

From ZCubes Wiki
Jump to navigation Jump to search
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==How to Apply Prime Numbers Twins, Cousins, Sexy Primes==
+
==Prime Numbers, Twin Primes, Cousins, Sexy Primes==
 
<br/>
 
<br/>
 
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,
 
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,
Line 8: Line 8:
 
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
 
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
  
 +
==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]) 
  
<<[[Learn_ZCubes | Learn ZCubes ]]
+
  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]
 +
 
 +
 
 +
 
 +
 
 +
<br/>
 +
*[[Z3 | Z3 home]]
 +
*[[Z^3 Language Documentation]]
 +
*[[ZCubes_Videos | ZCubes Videos and Tutorials]]
 +
*[[Main_Page | About ZCubes ]]
 +
<br/>
 
<br/>
 
<br/>
 
&copy; Copyright 1996-2020, ZCubes, Inc.
 
&copy; Copyright 1996-2020, ZCubes, Inc.

Latest revision as of 14:04, 14 September 2021

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.