Script computing the Primorial
sequence
//* Primorial
numbers
// Pn =
( 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,
71, 73, 79, 83, 89, 97 )
// OEIS for the Primorial sequence
A002110 = ( 1,
2, 6, 30, 210, 2310, 30030, 510510, 9699690, 223092870, 6469693230,
200560490130, 7420738134810, 304250263527210, 13082761331670030, 614889782588491410,
32589158477190044730, 1922760350154212639070, 117288381359406970983270,
7858321551080267055879090 )
computed
= [ 0 <= n < LENGTH A002110 ] ( (Pn(n)) #! )
ERRORS = [ 0
<= n < LENGTH A002110 ] ( A002110
- computed )
CALC computed
CALC ERRORS
Script output
// OEIS for the Primorial sequence
A002110 = ( 1,
2, 6, 30, 210, 2310, 30030, 510510, 9699690, 223092870, 6469693230,
200560490130, 7420738134810, 304250263527210, 13082761331670030,
614889782588491410, 32589158477190044730, 1922760350154212639070,
117288381359406970983270, 7858321551080267055879090 )
computed
= [ 0 <= n < LENGTH A002110 ] ( (Pn(n)) #! )
ERRORS = [ 0
<= n < LENGTH A002110 ] ( A002110
- computed )
CALC computed
(1, 2, 6, 30, 210, 2310, 30030,
510510, 9699690, 223092870, 6469693230, 200560490130, 7420738134810, 304250263527210,
13082761331670030, 614889782588491410, 32589158477190044730, 1922760350154212639070,
117288381359406970983270, 7858321551080267055879090)
CALC ERRORS
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0)
Script computing the Compositorial sequence
!! Compositorial
(n) = n! / ( n #! )
// OEIS for the Compositorial sequence
A036691 = ( 1, 4, 24, 192, 1728,
17280, 207360, 2903040, 43545600, 696729600, 12541132800, 250822656000,
5267275776000, 115880067072000, 2781121609728000, 69528040243200000,
1807729046323200000, 48808684250726400000, 1366643159020339200000 )
Cn = ( 1, 4, 6, 8, 9, 10, 12, 14,
15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, 34, 35, 36, 38, 39, 40,
42, 44, 45, 46, 48, 49, 50, 51, 52, 54, 55, 56, 57, 58, 60, 62, 63, 64, 65, 66,
68, 69, 70, 72 )
computed
= [ 0 <= n < LENGTH A036691 ] ( Compositorial (Cn#n) )
ERRORS = [ 0
<= n < LENGTH A036691 ] ( A036691
- computed )
CALC computed
CALC ERRORS
Script output
!! Compositorial
(n) = n! / ( n #! )
A036691 = ( 1,
4, 24, 192, 1728, 17280, 207360, 2903040, 43545600, 696729600, 12541132800,
250822656000, 5267275776000, 115880067072000, 2781121609728000,
69528040243200000, 1807729046323200000, 48808684250726400000,
1366643159020339200000 )
Cn = ( 1, 4, 6, 8, 9, 10, 12, 14,
15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, 34, 35, 36, 38, 39, 40,
42, 44, 45, 46, 48, 49, 50, 51, 52, 54, 55, 56, 57, 58, 60, 62, 63, 64, 65, 66,
68, 69, 70, 72 )
computed
= [ 0 <= n < LENGTH A036691 ] ( Compositorial (Cn#n) )
ERRORS = [ 0
<= n < LENGTH A036691 ] ( A036691
- computed )
CALC computed
(1, 4, 24, 192, 1728, 17280,
207360, 2903040, 43545600, 696729600, 12541132800, 250822656000, 5267275776000,
115880067072000, 2781121609728000, 69528040243200000, 1807729046323200000,
48808684250726400000, 1366643159020339200000)
CALC ERRORS
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0)
Script computing the Primorial
unit offsets
// look for primes at +1 and -1 from Primorials
Original source
// !! row
(n, pn, pnp) = ( n, pn, pnp-1, pnp+1 )
// !! calcPNP (n, pn) = row ( n, pn, pn #! )
// !! calcPN (n) = calcPNP ( n, Pn(n) )
// remaining = 28
// *{ remaining
// n = 30 - remaining
// CALC calcPN(n)
// }*
// alternative rendering of table
!! P(n) =
n #! ;
!! PNP (n) = P ( Pn n
)
!! PNPm1 (n) = PNP(n)
- 1 ;
!! PNPp1 (n) = PNP(n) + 1
// display as formatted table
tabulate [2 <= n
<= 30] ( n, Pn n, PNPm1(n) , PNPp1(n) )
// tables of prime counting
functions
!! pi(x)
= PIF x
// percent error of approximations
- xLx and li specifically respectively
!! pct (x,apx) = 100* (pi x - apx) / (pi x) ; !! pxlx(x) = pct ( x, xLx
x) ;
!! pli(x) = pct ( x, li x)
// a table of pi, x/log x, and li
giving values and percent error for each
tabulate [100
<= x <= 10000 <> 100] ( x,
pi x, xLx x, pxlx x, li x, pli x )
// table of prime counting parity
functions
tabulate [900 <= x <= 1000 <> 1] ( x, pi x, mu x, OMEGA x, omega x, lambda x )
Linear correlation of Sigma Ln Prime
//
============================================================
// using primorial in factorized system
init "net.myorb.math.primenumbers.PowerLibrary"
named "ln" op "LN"
!! check (n) = ln (n #!) - n
// 1 above
first 100 primes found using Pn in sequence 1..100
pf = [ 1 <= n <= 100 ] ( check (1
+ Pn n) )
// list errors of of log primorial
Pn n
CALC pf
// show as
table
remaining = 100
*{ remaining
n = 101 - remaining ; pp1 = 1 + Pn n
CALC (n, pp1, check (pp1) )
}*
!! lnp (n) = ln (n #!)
pp = [ 1 <= n <= 100 ] ( 1 + Pn n )
pf = [ 1 <= n <= 100 ] ( lnp (1 + Pn n) )
calc pp
calc pf
// regression
that runs in real number application
lc = FITLINE ( pf, pp )
calc lc
Script output
(1, 3, -1.2082405307719460)
(2, 4, -2.2082405307719460)
(3, 6, -2.5988026183378450)
(4, 8, -2.6528924692825310)
(5, 12, -4.2549971964841600)
(6, 14, -3.6900478390226300)
(7, 18, -4.8568344949664100)
(8, 20, -3.9123955157999800)
(9, 24, -4.7769012998708200)
(10, 30, -7.4096054698843500)
(11, 32, -5.9756182653992100)
(12, 38, -8.3647003527549800)
(13, 42, -8.6511282860506600)
(14, 44, -6.8899281703571100)
(15, 48, -7.0397805686470500)
(16, 54, -9.0694886550949100)
(17, 60, -10.9919512111892000)
(18, 62, -8.8810773470158800)
(19, 68, -10.6763847276249400)
(20, 72, -10.4137048505836000)
(21, 74, -8.1232454094352000)
(22, 80, -9.7537975569682000)
(23, 84, -9.3349569491716000)
(24, 90, -10.8463205794394500)
(25, 98, -14.2716096009360600)
(26, 102, -13.6564890840947800)
(27, 104, -11.0217600958651600)
(28, 108, -10.3489312614032600)
(29, 110, -7.6575833791742000)
(30, 114, -6.9301955604618000)
(31, 128, -16.0860084740032000)
(32, 132, -15.2108111508021000)
(33, 138, -16.2908302249740000)
(34, 140, -13.3563562918433000)
(35, 150, -18.3524099858978000)
(36, 152, -15.3351301490829000)
(37, 158, -16.2788843437346000)
(38, 164, -17.1851341429278000)
(39, 168, -16.0671403305111000)
(40, 174, -16.9138487360133000)
(41, 180, -17.7264629301725000)
(42, 182, -14.5279658989068000)
(43, 192, -19.2756924708600000)
(44, 194, -16.0130022819552000)
(45, 198, -14.7297985532172000)
(46, 200, -11.4364937284927000)
(47, 212, -18.0846355950166000)
(48, 224, -24.6774638235565000)
(49, 228, -23.2525138060751000)
(50, 230, -19.8187918025209000)
(51, 234, -18.3677533489552000)
(52, 240, -18.8912897970237000)
(53, 242, -15.4064928635330000)
(54, 252, -19.8810399244013000)
(55, 258, -20.3319638395060000)
(56, 264, -20.7598098073282000)
(57, 270, -21.1650984277264000)
(58, 272, -17.5629796068466000)
(59, 278, -17.9389621006594000)
(60, 282, -16.3006074313256000)
(61, 284, -12.6551605336824000)
(62, 294, -16.9749879246653000)
(63, 308, -25.2481401770782000)
(64, 312, -23.5083472648989000)
(65, 314, -19.7621440743587000)
(66, 318, -18.0032423004815000)
(67, 332, -26.2011239251044000)
(68, 338, -26.3810409947520000)
(69, 348, -30.5317162148051000)
(70, 350, -26.6766442926028000)
(71, 354, -24.8101762356694000)
(72, 360, -24.9268538471812000)
(73, 368, -27.0214919991266000)
(74, 374, -27.0999135794828000)
(75, 380, -27.1623773744004000)
(76, 384, -25.2143423852197000)
(77, 390, -25.2507630416012000)
(78, 398, -27.2668267609141000)
(79, 402, -25.2728653336075000)
(80, 410, -27.2591501775647000)
(81, 420, -31.2212792576425000)
(82, 422, -27.1786464239601000)
(83, 432, -31.1125383338563000)
(84, 434, -27.0418006058540000)
(85, 440, -26.9573011927788000)
(86, 444, -24.8637314227337000)
(87, 450, -24.7567085349914000)
(88, 458, -26.6320251440972000)
(89, 462, -24.4986271011003000)
(90, 464, -20.3609000470143000)
(91, 468, -18.2145707893454000)
(92, 480, -24.0428701919344000)
(93, 488, -25.8546060688519000)
(94, 492, -23.6581619410572000)
(95, 500, -25.4455558453058000)
(96, 504, -23.2249656752061000)
(97, 510, -22.9925176586555000)
(98, 522, -28.7367676169022000)
(99, 524, -24.4771861528374000)
(100, 542, -36.1837668739908000)
!! lnp (n) = ln (n #!)
pp = [ 1
<= n <= 100 ] ( 1 + Pn n )
pf = [ 1
<= n <= 100 ] ( lnp (1 + Pn n) )
calc pp
(3, 4, 6, 8, 12, 14, 18, 20, 24,
30, 32, 38, 42, 44, 48, 54, 60, 62, 68, 72, 74, 80, 84, 90, 98, 102, 104, 108,
110, 114, 128, 132, 138, 140, 150, 152, 158, 164, 168, 174, 180, 182, 192, 194,
198, 200, 212, 224, 228, 230, 234, 240, 242, 252, 258, 264, 270, 272, 278, 282,
284, 294, 308, 312, 314, 318, 332, 338, 348, 350, 354, 360, 368, 374, 380, 384,
390, 398, 402, 410, 420, 422, 432, 434, 440, 444, 450, 458, 462, 464, 468, 480,
488, 492, 500, 504, 510, 522, 524, 542)
calc pf
(1.7917594692280540,
1.7917594692280540, 3.4011973816621550, 5.3471075307174690, 7.7450028035158400,
10.3099521609773700, 13.1431655050335900, 16.0876044842000200,
19.2230987001291800, 22.5903945301156500, 26.0243817346007900,
29.6352996472450200, 33.3488717139493400, 37.1100718296428900,
40.9602194313529500, 44.9305113449050900, 49.0080487888108000,
53.1189226529841200, 57.3236152723750600, 61.5862951494164000,
65.8767545905648000, 70.2462024430318000, 74.6650430508284000,
79.1536794205605500, 83.7283903990639400, 88.3435109159052200,
92.9782399041348400, 97.6510687385967400, 102.3424166208258000,
107.0698044395382000, 111.9139915259968000, 116.7891888491979000,
121.7091697750260000, 126.6436437081567000, 131.6475900141022000,
136.6648698509171000, 141.7211156562654000, 146.8148658570722000,
151.9328596694889000, 157.0861512639867000, 162.2735370698275000,
167.4720341010932000, 172.7243075291400000, 177.9869977180448000,
183.2702014467828000, 188.5635062715073000, 193.9153644049834000,
199.3225361764435000, 204.7474861939249000, 210.1812081974791000,
215.6322466510448000, 221.1087102029763000, 226.5935071364670000,
232.1189600755987000, 237.6680361604940000, 243.2401901926718000,
248.8349015722736000, 254.4370203931534000, 260.0610378993406000,
265.6993925686744000, 271.3448394663176000, 277.0250120753347000,
282.7518598229218000, 288.4916527351011000, 294.2378559256413000,
299.9967576995185000, 305.7988760748956000, 311.6189590052480000,
317.4682837851949000, 323.3233557073972000, 329.1898237643306000,
335.0731461528188000, 340.9785080008734000, 346.9000864205172000,
352.8376226255996000, 358.7856576147803000, 364.7492369583988000,
370.7331732390859000, 376.7271346663925000, 382.7408498224353000,
388.7787207423575000, 394.8213535760399000, 400.8874616661437000,
406.9581993941460000, 413.0426988072212000, 419.1362685772663000, 425.2432914650086000,
431.3679748559028000, 437.5013728988997000, 443.6390999529857000,
449.7854292106546000, 455.9571298080656000, 462.1453939311481000,
468.3418380589428000, 474.5544441546942000, 480.7750343247939000,
487.0074823413445000, 493.2632323830978000, 499.5228138471626000,
505.8162331260092000)
// regression that runs in real
number application
Linear regression
Y = 6.98758 + 1.04715 * x
Wilson's theorem
// Wilson's theorem demonstration script
// integers result from primes
!! wilsons (k) = ( (k - 1)! + 1 )
/ k
ws = [ 0 < j < 50 ] ( wilsons
j )
prettyprint ws
ws =
[
1 2
2 1
3 1
1.7500000000000000
5 5
20.1666666666666667
7 103
630.1250000000000000
4480.1111111111111112
36288.1000000000000000
11 329891
3326400.0833333333333334
13 36846277
444787200.0714285714285715
5811886080.0666666666666667
81729648000.0625000000000000
17 1230752346353
19760412672000.0555555555555556
19 336967037143579
6082255020441600.0500000000000000
115852476579840000.0476190476190477
2322315553259520000.0454545454545455
23 48869596859895986087
1077167364120207360000.0416666666666667
24817936069329577574400.0400000000000000
596585001666576384000000.0384615384615385
14936720782466875392000000.0370370370370371
388888194657798291456000000.0357142857142858
29 10513391193507374500051862069
294725399791323398484787200000.0333333333333334
31 8556543864909388988268015483871
256963707943060088053923840000000.0312500000000000
7973661725263440308097515520000000.0303030303030304
255391694670937838103476305920000000.0294117647058824
8435222829702975452789103132672000000.0285714285714286
287031887955170692490740314931200000000.0277777777777778
37 10053873697024357228864849950022572972973
362204028716482764376736304778444800000000.0263157894736843
13410836345297464404102749335899340800000000.0256410256410257
509947052029936083966007043497572433920000000.0250000000000000
41 19900372762143847179161250477954046201756097561
796488728884852550194525286986684563456000000000.0238095238095239
43 32674560877973951128910293168477013254334511627907
1373074160531223537212616637920772670619648000000000.0227272727272728
59072701661965528178747240244769242007103078400000000.0222222222222223
2600483062293047707868764380340385110095298560000000000.0217391304347827
47 117077067230044445741495860187239465807694718148085106383
5387984198149337096728424065700249582691617341440000000000.0208333333333334
253345216174205564711475286681089286500438497034240000000000.0204081632653062
]
In algebra and number theory, Wilson's
theorem states that a natural number n >
1 is a prime
number if and only if the product of all the positive integers less
than n is one less than a multiple of n.
That is (using the notations of modular arithmetic), the factorial (n-1)! Satisfies
-1 (mod n) exactly when n is a prime number. In other words,
any number n is a prime number if, and only if, (n − 1)! + 1
is divisible by n.[1]
https://en.wikipedia.org/wiki/Wilson%27s_theorem