Difference between revisions of "ZCubes/How to Apply Prime Numbers Twins, Cousins, Sexy Primes"
Jump to navigation
Jump to search
(→Code) |
(→Code) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | == | + | ==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 7: | Line 7: | ||
{{#ev:youtube|pOMlG-FG4T4|480|left|Prime Numbers Twins, Cousins, Sexy Primes}} | {{#ev:youtube|pOMlG-FG4T4|480|left|Prime Numbers Twins, Cousins, Sexy Primes}} | ||
<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== | ==Code== | ||
PRIMES(100) | PRIMES(100) | ||
− | . | + | .map( |
− | + | (x,i,d)=> | |
− | .$(x=>x | + | [ |
− | + | 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] | ||
− | < | + | |
+ | |||
+ | <br/> | ||
+ | *[[Z3 | Z3 home]] | ||
+ | *[[Z^3 Language Documentation]] | ||
+ | *[[ZCubes_Videos | ZCubes Videos and Tutorials]] | ||
+ | *[[Main_Page | About ZCubes ]] | ||
+ | <br/> | ||
<br/> | <br/> | ||
© Copyright 1996-2020, ZCubes, Inc. | © 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
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.