Generalized Twin Goldbach Primes(Clojure & JSR-331 - Puzzles)

13

Click here to load reader

description

GENERALIZED TWIN GOLDBACH PRIMES OSCAR RIVEROS Abstract. Experiments, structural patterns and behavior of prime numbers,with Clojure & JSR-331. Clojure & JSR-331 - Puzzles is a set of problemsof finite CONSTRAINT LOGIC PROGRAMMING of FINITE DOMAINS, inthis document are specifically addressed in Clojure & JSR-331 API The JavaConstraint Programming. Itself is a personal investigation, non-profit, is onlyshared to the public for what it is, a personal study of the issue being raised.

Transcript of Generalized Twin Goldbach Primes(Clojure & JSR-331 - Puzzles)

Page 1: Generalized Twin Goldbach Primes(Clojure & JSR-331 - Puzzles)

GENERALIZED TWIN GOLDBACH PRIMES

OSCAR RIVEROS

Abstract. Experiments, structural patterns and behavior of prime numbers,with Clojure & JSR-331. Clojure & JSR-331 - Puzzles is a set of problemsof finite CONSTRAINT LOGIC PROGRAMMING of FINITE DOMAINS, inthis document are specifically addressed in Clojure & JSR-331 API The JavaConstraint Programming. Itself is a personal investigation, non-profit, is onlyshared to the public for what it is, a personal study of the issue being raised.

February25, 2013

Definition 1. We say that 2n is a Generalized Twin-Goldbach number if it can bewritten by a sum of two primes, say p and q but also between the latter must bethe following relationship q = 2k + p, where 2k (an even number) is the coefficient2k − Twin.

Theorem 1. Let t2ki , t2lj two Generalized Twin-Goldbach numbers of the families2k and 2l respectively then t2ki = pi+qi = pi+pi+2k = 2pi+2k and t2lj = 2pj +2l

then t2lj − t2ki = 2[(pj − pi) + (l − k)] for all i, j, l, k.

Corollary 1. Let t2ki , t2ki′

two Generalized Twin-Goldbach numbers of same family2k then t2ki − t2k

i′ ‘= 2(pi − pi′ ) for all i, i

′, 2k.

Problem 1. Create an algorithm that computes all Generalized Twin-Goldbachnumbers in an interval, and also let it record and 2k − Twin coefficient 2k v/sGeneralized Twin-Goldbach number.

Algorithm 1.( ns cpwp . twin−go ldbach

( : use [ cpwp . core ] )( : use [ c l o j u r e . j ava . i o ] )( : import [ j a vax . c o n s t r a i n t s

ProblemProblemFactoryVar ] ) )

( d e f problem n i l )( d e f top 1000)( de f twin 2)( de f num−solutions 0)

( de fn prime?[max ]( not−any? zero ? (map #(rem max %) ( range 2 max ) ) ) )

( de fn get−primes−domain[max ]

Key words and phrases. Clojure, JSR-331, Primes, Goldbach, Twin.1

Page 2: Generalized Twin Goldbach Primes(Clojure & JSR-331 - Puzzles)

GENERALIZED TWIN GOLDBACH PRIMES 2

( l e t [ primes ( cons 2 ( f o r [ x ( range 3 max 2) : when ( prime? x ) ] x ) ) ]( in t−array primes ) ) )

( de fn make−primes− l i s t[ p r e f i x l max ]( l e t [ ? l i s t ’ ( ) ]( f o r [ i ( range l ) ]

( cond ? l i s t ( . v a r i a b l e problem ( s t r p r e f i x i ) ( get−primes−domain max ) ) ) ) ) )

( de fn so lu t i on− tw ing−go ldbach[ ]( l e t [ primes ( get−primes−domain top )

l eng th 2evens ( int−array ( range 2 top 2))n ( . v a r i a b l e problem "n" evens )q ( make−primes− l i s t "q" l eng th top ) ]

( . p o s tA l l D i f f e r e n t problem ( i n t o [ ] ( concat [ n ] q ) ) )( . po s t problem ( into−array I n t e g e r /TYPE ( repeat l eng th 1)) ( into−array Var q ) "=" n)( . po s t problem ( . p l u s ( f i r s t q ) twin ) "=" ( l a s t q ) ) ) )

( de fn math[ ne x t− s o l u t i on ]( l e t [ p ( . ge tVa lue nex t− s o l u t i on "q0" )

q ( . ge tVa lue nex t− s o l u t i on "q1" )n ( . ge tVa lue nex t− s o l u t i on "n" ) ]

( d e f num−solutions (+ num−solutions 1))( with−open [ wrtr ( c l o j u r e . j ava . i o / w r i t e r

( s t r "/Google ␣Drive /tmp/Goldbach / goldbach−twin−" twin " . t x t " ): append t r u e ) ]

( . w r i t e wrtr ( s t r n " , " p " , " q "\n" ) ) ) ) )

( doseq [ i ( range 2 top 2 ) ]( d e f twin i )( d e f problem ( ProblemFactory /newProblem ( s t r "Goldbach ’ s ␣Conjec ture : ␣ t=" twin ) ) )( d e f num−solutions 0)( solve−math problem so lu t i on− tw ing−go ldbach math )( with−open [ wrtr ( c l o j u r e . j ava . i o / w r i t e r

( s t r "/Google ␣Drive /tmp/Goldbach / go ldbach− twin . t x t " ): append t r u e ) ]

( . w r i t e wrtr ( s t r twin " , " num−solutions "\n" ) ) ) )

Note 1. In the repository project, there is a zip file with∼ 1000 files with allsolutions. (https://github.com/maxtuno/Clojure—JSR-331—Puzzles)

Conclusion 1.2k Nº o fTwin Genera l i zed

Twin−Goldbachnumber (1000)

−−−−−−−−−−−−−−−−−−−−2 244 266 468 2410 3212 4714 2816 24

Page 3: Generalized Twin Goldbach Primes(Clojure & JSR-331 - Puzzles)

GENERALIZED TWIN GOLDBACH PRIMES 3

18 4320 3122 2524 4626 2528 2530 5932 2234 2636 4738 2340 3142 5244 2446 2348 4350 2852 2454 4156 2858 1960 5662 2064 2166 4868 2170 3372 3974 2176 2378 4180 2682 2384 4786 2188 2190 5392 2194 2296 3898 24100 24102 40104 23106 19

Page 4: Generalized Twin Goldbach Primes(Clojure & JSR-331 - Puzzles)

GENERALIZED TWIN GOLDBACH PRIMES 4

108 37110 25112 22114 37116 20118 21120 49122 18124 21126 45128 19130 24132 39134 19136 20138 35140 28142 17144 36146 20148 18150 47152 19154 24156 39158 18160 26162 35164 16166 18168 41170 24172 18174 38176 20178 18180 42182 21184 17186 36188 19190 25192 33194 19196 20

Page 5: Generalized Twin Goldbach Primes(Clojure & JSR-331 - Puzzles)

GENERALIZED TWIN GOLDBACH PRIMES 5

198 34200 20202 16204 37206 17208 20210 50212 14214 15216 35218 18220 26222 33224 20226 19228 34230 22232 17234 35236 15238 21240 43242 14244 16246 34248 16250 24252 35254 17256 15258 30260 24262 14264 35266 22268 14270 41272 15274 14276 31278 14280 23282 27284 17286 18

Page 6: Generalized Twin Goldbach Primes(Clojure & JSR-331 - Puzzles)

GENERALIZED TWIN GOLDBACH PRIMES 6

288 27290 21292 16294 34296 17298 12300 39302 13304 14306 33308 20310 19312 28314 15316 16318 26320 18322 17324 28326 18328 16330 41332 14334 13336 36338 14340 18342 30344 15346 16348 29350 24352 14354 24356 16358 13360 37362 15364 17366 28368 15370 20372 27374 16376 17

Page 7: Generalized Twin Goldbach Primes(Clojure & JSR-331 - Puzzles)

GENERALIZED TWIN GOLDBACH PRIMES 7

378 30380 18382 14384 27386 13388 12390 37392 15394 13396 28398 13400 15402 27404 14406 17408 27410 16412 14414 27416 14418 15420 39422 11424 13426 26428 14430 16432 24434 15436 15438 23440 17442 13444 23446 12448 14450 32452 11454 13456 22458 12460 17462 26464 13466 10

Page 8: Generalized Twin Goldbach Primes(Clojure & JSR-331 - Puzzles)

GENERALIZED TWIN GOLDBACH PRIMES 8

468 25470 14472 9474 20476 13478 11480 28482 13484 12486 21488 11490 16492 21494 14496 13498 19500 14502 11504 26506 11508 8510 29512 12514 9516 22518 14520 14522 15524 12526 10528 23530 13532 9534 25536 10538 11540 24542 12544 11546 25548 9550 14552 21554 12556 10

Page 9: Generalized Twin Goldbach Primes(Clojure & JSR-331 - Puzzles)

GENERALIZED TWIN GOLDBACH PRIMES 9

558 19560 18562 10564 21566 10568 8570 25572 12574 11576 21578 11580 14582 18584 11586 8588 21590 15592 7594 22596 11598 8600 21602 13604 10606 18608 9610 10612 18614 9616 10618 13620 12622 8624 16626 8628 6630 24632 8634 9636 16638 11640 10642 14644 9646 9

Page 10: Generalized Twin Goldbach Primes(Clojure & JSR-331 - Puzzles)

GENERALIZED TWIN GOLDBACH PRIMES 10

648 16650 11652 5654 15656 10658 8660 20662 8664 8666 13668 8670 10672 18674 8676 5678 13680 11682 7684 12686 9688 7690 17692 6694 5696 13698 10700 8702 12704 7706 5708 12710 8712 6714 15716 10718 5720 16722 10724 6726 15728 9730 9732 12734 5736 7

Page 11: Generalized Twin Goldbach Primes(Clojure & JSR-331 - Puzzles)

GENERALIZED TWIN GOLDBACH PRIMES 11

738 11740 9742 5744 11746 7748 6750 16752 6754 8756 14758 6760 7762 8764 6766 7768 12770 9772 3774 11776 6778 7780 15782 6784 8786 11788 4790 7792 11794 6796 5798 11800 6802 5804 10806 7808 6810 11812 5814 5816 12818 6820 7822 8824 6826 5

Page 12: Generalized Twin Goldbach Primes(Clojure & JSR-331 - Puzzles)

GENERALIZED TWIN GOLDBACH PRIMES 12

828 7830 4832 3834 8836 6838 3840 11842 3844 5846 9848 5850 6852 7854 5856 3858 6860 5862 2864 6866 4868 4870 7872 3874 4876 7878 5880 3882 4884 3886 1888 5890 3892 2894 4896 3898 3900 7902 2904 4906 5908 3910 4912 4914 2916 4

Page 13: Generalized Twin Goldbach Primes(Clojure & JSR-331 - Puzzles)

GENERALIZED TWIN GOLDBACH PRIMES 13

918 4920 1922 3924 5926 2928 2930 4932 1934 4936 4938 2940 2942 2944 2946 1948 3950 2952 1954 2956 1958 2960 3962 1964 3966 2968 1970 2972 2974 1976 1978 1980 1982 0984 1986 1988 1990 0992 0994 0996 0998 0

(http://mx-clojure.blogspot.com)