mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   Math (https://www.mersenneforum.org/forumdisplay.php?f=8)
-   -   result of combination ( few numbers) (https://www.mersenneforum.org/showthread.php?t=22330)

pepi37 2017-05-22 22:43

result of combination ( few numbers)
 
Does anybody know is there web page that will give me output for number combinations
For example ( 1 3 5 7 9 ) without doubling

11111
11113
11131
11311
13111
11115
11151
11511
15111
....

science_man_88 2017-05-22 22:55

[QUOTE=pepi37;459552]Does anybody know is there web page that will give me output for number combinations
For example ( 1 3 5 7 9 ) without doubling

11111
11113
11131
11311
13111
11115
11151
11511
15111
....[/QUOTE]

the OEIS ( Online Encyclopedia of Integer Sequences) wasn't available ? I'll see what I can find I think I understand what you are looking for and may even be able to give you code for PARI/GP.[CODE]for(x=1,10000,if(x<10||(#select(r->r=="1",Vec(Str(x)),1)<=length(Str(x))/2&&#select(r->r=="3",Vec(Str(x)),1)<=length(Str(x))/2&&#select(r->r=="5",Vec(Str(x)),1)<=length(Str(x))/2&&#select(r-
>r=="7",Vec(Str(x)),1)<=length(Str(x))/2&&#select(r->r=="9",Vec(Str(x)),1)<=length(Str(x))/2),print(x)))[/CODE] basically this code uses some help from the pigeon hole principle to start to weed them out. if a number contains more than ceil( length(Str(x))/2) characters that are the same there are automatically three that are together. ( yes I know I forgot the ceil for the odd number cases and yes I know there are a lot of others to weed out.

a1call 2017-05-22 23:45

Not most efficient code but it should work.

[CODE]theCounter = 19
theOldString = ""
forstep(i1=1,9,2,{
forstep(i2=1,9,2,
forstep(i3=1,9,2,
forstep(i4=1,9,2,
forstep(i5=1,9,2,
theString = Str(i1,i2,i3,i4,i5) ;
if (theOldString != theString ,
theOldString = theString;
print(theString );
);
theCounter = theCounter -1;
if (theCounter <1, next(19););
);
);
);
);
})

[/CODE]


[CODE]11111
11113
11115
11117
11119
11131
11133
11135
11137
11139
11151
11153
11155
11157
11159
11171
11173
11175
11177[/CODE]

science_man_88 2017-05-23 00:00

[QUOTE=a1call;459555]Not most efficient code but it should work.
[/QUOTE]

I'm actually realizing, we both missed the mark. The list they give, is the ones they seem to have wanted to avoid and they wanted a count not a print of them all and they asked for a site but I think it more comes down to hamming weight which I should have checked instead. to the OP [url]https://math.stackexchange.com/questions/474741/formula-for-combinations-with-replacement[/url] might be a good read.

pepi37 2017-05-23 00:06

I just need code that I can run. It doesnot to be exacly web page.
And to get output in txt file....

a1call 2017-05-23 00:15

Here is the complete run:

[CODE]11111
11113
11115
11117
11119
11131
11133
11135
11137
11139
11151
11153
11155
11157
11159
11171
11173
11175
11177
11179
11191
11193
11195
11197
11199
11311
11313
11315
11317
11319
11331
11333
11335
11337
11339
11351
11353
11355
11357
11359
11371
11373
11375
11377
11379
11391
11393
11395
11397
11399
11511
11513
11515
11517
11519
11531
11533
11535
11537
11539
11551
11553
11555
11557
11559
11571
11573
11575
11577
11579
11591
11593
11595
11597
11599
11711
11713
11715
11717
11719
11731
11733
11735
11737
11739
11751
11753
11755
11757
11759
11771
11773
11775
11777
11779
11791
11793
11795
11797
11799
11911
11913
11915
11917
11919
11931
11933
11935
11937
11939
11951
11953
11955
11957
11959
11971
11973
11975
11977
11979
11991
11993
11995
11997
11999
13111
13113
13115
13117
13119
13131
13133
13135
13137
13139
13151
13153
13155
13157
13159
13171
13173
13175
13177
13179
13191
13193
13195
13197
13199
13311
13313
13315
13317
13319
13331
13333
13335
13337
13339
13351
13353
13355
13357
13359
13371
13373
13375
13377
13379
13391
13393
13395
13397
13399
13511
13513
13515
13517
13519
13531
13533
13535
13537
13539
13551
13553
13555
13557
13559
13571
13573
13575
13577
13579
13591
13593
13595
13597
13599
13711
13713
13715
13717
13719
13731
13733
13735
13737
13739
13751
13753
13755
13757
13759
13771
13773
13775
13777
13779
13791
13793
13795
13797
13799
13911
13913
13915
13917
13919
13931
13933
13935
13937
13939
13951
13953
13955
13957
13959
13971
13973
13975
13977
13979
13991
13993
13995
13997
13999
15111
15113
15115
15117
15119
15131
15133
15135
15137
15139
15151
15153
15155
15157
15159
15171
15173
15175
15177
15179
15191
15193
15195
15197
15199
15311
15313
15315
15317
15319
15331
15333
15335
15337
15339
15351
15353
15355
15357
15359
15371
15373
15375
15377
15379
15391
15393
15395
15397
15399
15511
15513
15515
15517
15519
15531
15533
15535
15537
15539
15551
15553
15555
15557
15559
15571
15573
15575
15577
15579
15591
15593
15595
15597
15599
15711
15713
15715
15717
15719
15731
15733
15735
15737
15739
15751
15753
15755
15757
15759
15771
15773
15775
15777
15779
15791
15793
15795
15797
15799
15911
15913
15915
15917
15919
15931
15933
15935
15937
15939
15951
15953
15955
15957
15959
15971
15973
15975
15977
15979
15991
15993
15995
15997
15999
17111
17113
17115
17117
17119
17131
17133
17135
17137
17139
17151
17153
17155
17157
17159
17171
17173
17175
17177
17179
17191
17193
17195
17197
17199
17311
17313
17315
17317
17319
17331
17333
17335
17337
17339
17351
17353
17355
17357
17359
17371
17373
17375
17377
17379
17391
17393
17395
17397
17399
17511
17513
17515
17517
17519
17531
17533
17535
17537
17539
17551
17553
17555
17557
17559
17571
17573
17575
17577
17579
17591
17593
17595
17597
17599
17711
17713
17715
17717
17719
17731
17733
17735
17737
17739
17751
17753
17755
17757
17759
17771
17773
17775
17777
17779
17791
17793
17795
17797
17799
17911
17913
17915
17917
17919
17931
17933
17935
17937
17939
17951
17953
17955
17957
17959
17971
17973
17975
17977
17979
17991
17993
17995
17997
17999
19111
19113
19115
19117
19119
19131
19133
19135
19137
19139
19151
19153
19155
19157
19159
19171
19173
19175
19177
19179
19191
19193
19195
19197
19199
19311
19313
19315
19317
19319
19331
19333
19335
19337
19339
19351
19353
19355
19357
19359
19371
19373
19375
19377
19379
19391
19393
19395
19397
19399
19511
19513
19515
19517
19519
19531
19533
19535
19537
19539
19551
19553
19555
19557
19559
19571
19573
19575
19577
19579
19591
19593
19595
19597
19599
19711
19713
19715
19717
19719
19731
19733
19735
19737
19739
19751
19753
19755
19757
19759
19771
19773
19775
19777
19779
19791
19793
19795
19797
19799
19911
19913
19915
19917
19919
19931
19933
19935
19937
19939
19951
19953
19955
19957
19959
19971
19973
19975
19977
19979
19991
19993
19995
19997
19999
31111
31113
31115
31117
31119
31131
31133
31135
31137
31139
31151
31153
31155
31157
31159
31171
31173
31175
31177
31179
31191
31193
31195
31197
31199
31311
31313
31315
31317
31319
31331
31333
31335
31337
31339
31351
31353
31355
31357
31359
31371
31373
31375
31377
31379
31391
31393
31395
31397
31399
31511
31513
31515
31517
31519
31531
31533
31535
31537
31539
31551
31553
31555
31557
31559
31571
31573
31575
31577
31579
31591
31593
31595
31597
31599
31711
31713
31715
31717
31719
31731
31733
31735
31737
31739
31751
31753
31755
31757
31759
31771
31773
31775
31777
31779
31791
31793
31795
31797
31799
31911
31913
31915
31917
31919
31931
31933
31935
31937
31939
31951
31953
31955
31957
31959
31971
31973
31975
31977
31979
31991
31993
31995
31997
31999
33111
33113
33115
33117
33119
33131
33133
33135
33137
33139
33151
33153
33155
33157
33159
33171
33173
33175
33177
33179
33191
33193
33195
33197
33199
33311
33313
33315
33317
33319
33331
33333
33335
33337
33339
33351
33353
33355
33357
33359
33371
33373
33375
33377
33379
33391
33393
33395
33397
33399
33511
33513
33515
33517
33519
33531
33533
33535
33537
33539
33551
33553
33555
33557
33559
33571
33573
33575
33577
33579
33591
33593
33595
33597
33599
33711
33713
33715
33717
33719
33731
33733
33735
33737
33739
33751
33753
33755
33757
33759
33771
33773
33775
33777
33779
33791
33793
33795
33797
33799
33911
33913
33915
33917
33919
33931
33933
33935
33937
33939
33951
33953
33955
33957
33959
33971
33973
33975
33977
33979
33991
33993
33995
33997
33999
35111
35113
35115
35117
35119
35131
35133
35135
35137
35139
35151
35153
35155
35157
35159
35171
35173
35175
35177
35179
35191
35193
35195
35197
35199
35311
35313
35315
35317
35319
35331
35333
35335
35337
35339
35351
35353
35355
35357
35359
35371
35373
35375
35377
35379
35391
35393
35395
35397
35399
35511
35513
35515
35517
35519
35531
35533
35535
35537
35539
35551
35553
35555
35557
35559
35571
35573
35575
35577
35579
35591
35593
35595
35597
35599
35711
35713
35715
35717
35719
35731
35733
35735
35737
35739
35751
35753
35755
35757
35759
35771
35773
35775
35777
35779
35791
35793
35795
35797
35799
35911
35913
35915
35917
35919
35931
35933
35935
35937
35939
35951
35953
35955
35957
35959
35971
35973
35975
35977
35979
35991
35993
35995
35997
35999
37111
37113
37115
37117
37119
37131
37133
37135
37137
37139
37151
37153
37155
37157
37159
37171
37173
37175
37177
37179
37191
37193
37195
37197
37199
37311
37313
37315
37317
37319
37331
37333
37335
37337
37339
37351
37353
37355
37357
37359
37371
37373
37375
37377
37379
37391
37393
37395
37397
37399
37511
37513
37515
37517
37519
37531
37533
37535
37537
37539
37551
37553
37555
37557
37559
37571
37573
37575
37577
37579
37591
37593
37595
37597
37599
37711
37713
37715
37717
37719
37731
37733
37735
37737
37739
37751
37753
37755
37757
37759
37771
37773
37775
37777
37779
37791
37793
37795
37797
37799
37911
37913
37915
37917
37919
37931
37933
37935
37937
37939
37951
37953
37955
37957
37959
37971
37973
37975
37977
37979
37991
37993
37995
37997
37999
39111
39113
39115
39117
39119
39131
39133
39135
39137
39139
39151
39153
39155
39157
39159
39171
39173
39175
39177
39179
39191
39193
39195
39197
39199
39311
39313
39315
39317
39319
39331
39333
39335
39337
39339
39351
39353
39355
39357
39359
39371
39373
39375
39377
39379
39391
39393
39395
39397
39399
39511
39513
39515
39517
39519
39531
39533
39535
39537
39539
39551
39553
39555
39557
39559
39571
39573
39575
39577
39579
39591
39593
39595
39597
39599
39711
39713
39715
39717
39719
39731
39733
39735
39737
39739
39751
39753
39755
39757
39759
39771
39773
39775
39777
39779
39791
39793
39795
39797
39799
39911
39913
39915
39917
39919
39931
39933
39935
39937
39939
39951
39953
39955
39957
39959
39971
39973
39975
39977
39979
39991
39993
39995
39997
39999
51111
51113
51115
51117
51119
51131
51133
51135
51137
51139
51151
51153
51155
51157
51159
51171
51173
51175
51177
51179
51191
51193
51195
51197
51199
51311
51313
51315
51317
51319
51331
51333
51335
51337
51339
51351
51353
51355
51357
51359
51371
51373
51375
51377
51379
51391
51393
51395
51397
51399
51511
51513
51515
51517
51519
51531
51533
51535
51537
51539
51551
51553
51555
51557
51559
51571
51573
51575
51577
51579
51591
51593
51595
51597
51599
51711
51713
51715
51717
51719
51731
51733
51735
51737
51739
51751
51753
51755
51757
51759
51771
51773
51775
51777
51779
51791
51793
51795
51797
51799
51911
51913
51915
51917
51919
51931
51933
51935
51937
51939
51951
51953
51955
51957
51959
51971
51973
51975
51977
51979
51991
51993
51995
51997
51999
53111
53113
53115
53117
53119
53131
53133
53135
53137
53139
53151
53153
53155
53157
53159
53171
53173
53175
53177
53179
53191
53193
53195
53197
53199
53311
53313
53315
53317
53319
53331
53333
53335
53337
53339
53351
53353
53355
53357
53359
53371
53373
53375
53377
53379
53391
53393
53395
53397
53399
53511
53513
53515
53517
53519
53531
53533
53535
53537
53539
53551
53553
53555
53557
53559
53571
53573
53575
53577
53579
53591
53593
53595
53597
53599
53711
53713
53715
53717
53719
53731
53733
53735
53737
53739
53751
53753
53755
53757
53759
53771
53773
53775
53777
53779
53791
53793
53795
53797
53799
53911
53913
53915
53917
53919
53931
53933
53935
53937
53939
53951
53953
53955
53957
53959
53971
53973
53975
53977
53979
53991
53993
53995
53997
53999
55111
55113
55115
55117
55119
55131
55133
55135
55137
55139
55151
55153
55155
55157
55159
55171
55173
55175
55177
55179
55191
55193
55195
55197
55199
55311
55313
55315
55317
55319
55331
55333
55335
55337
55339
55351
55353
55355
55357
55359
55371
55373
55375
55377
55379
55391
55393
55395
55397
55399
55511
55513
55515
55517
55519
55531
55533
55535
55537
55539
55551
55553
55555
55557
55559
55571
55573
55575
55577
55579
55591
55593
55595
55597
55599
55711
55713
55715
55717
55719
55731
55733
55735
55737
55739
55751
55753
55755
55757
55759
55771
55773
55775
55777
55779
55791
55793
55795
55797
55799
55911
55913
55915
55917
55919
55931
55933
55935
55937
55939
55951
55953
55955
55957
55959
55971
55973
55975
55977
55979
55991
55993
55995
55997
55999
57111
57113
57115
57117
57119
57131
57133
57135
57137
57139
57151
57153
57155
57157
57159
57171
57173
57175
57177
57179
57191
57193
57195
57197
57199
57311
57313
57315
57317
57319
57331
57333
57335
57337
57339
57351
57353
57355
57357
57359
57371
57373
57375
57377
57379
57391
57393
57395
57397
57399
57511
57513
57515
57517
57519
57531
57533
57535
57537
57539
57551
57553
57555
57557
57559
57571
57573
57575
57577
57579
57591
57593
57595
57597
57599
57711
57713
57715
57717
57719
57731
57733
57735
57737
57739
57751
57753
57755
57757
57759
57771
57773
57775
57777
57779
57791
57793
57795
57797
57799
57911
57913
57915
57917
57919
57931
57933
57935
57937
57939
57951
57953
57955
57957
57959
57971
57973
57975
57977
57979
57991
57993
57995
57997
57999
59111
59113
59115
59117
59119
59131
59133
59135
59137
59139
59151
59153
59155
59157
59159
59171
59173
59175
59177
59179
59191
59193
59195
59197
59199
59311
59313
59315
59317
59319
59331
59333
59335
59337
59339
59351
59353
59355
59357
59359
59371
59373
59375
59377
59379
59391
59393
59395
59397
59399
59511
59513
59515
59517
59519
59531
59533
59535
59537
59539
59551
59553
59555
59557
59559
59571
59573
59575
59577
59579
59591
59593
59595
59597
59599
59711
59713
59715
59717
59719
59731
59733
59735
59737
59739
59751
59753
59755
59757
59759
59771
59773
59775
59777
59779
59791
59793
59795
59797
59799
59911
59913
59915
59917
59919
59931
59933
59935
59937
59939
59951
59953
59955
59957
59959
59971
59973
59975
59977
59979
59991
59993
59995
59997
59999
71111
71113
71115
71117
71119
71131
71133
71135
71137
71139
71151
71153
71155
71157
71159
71171
71173
71175
71177
71179
71191
71193
71195
71197
71199
71311
71313
71315
71317
71319
71331
71333
71335
71337
71339
71351
71353
71355
71357
71359
71371
71373
71375
71377
71379
71391
71393
71395
71397
71399
71511
71513
71515
71517
71519
71531
71533
71535
71537
71539
71551
71553
71555
71557
71559
71571
71573
71575
71577
71579
71591
71593
71595
71597
71599
71711
71713
71715
71717
71719
71731
71733
71735
71737
71739
71751
71753
71755
71757
71759
71771
71773
71775
71777
71779
71791
71793
71795
71797
71799
71911
71913
71915
71917
71919
71931
71933
71935
71937
71939
71951
71953
71955
71957
71959
71971
71973
71975
71977
71979
71991
71993
71995
71997
71999
73111
73113
73115
73117
73119
73131
73133
73135
73137
73139
73151
73153
73155
73157
73159
73171
73173
73175
73177
73179
73191
73193
73195
73197
73199
73311
73313
73315
73317
73319
73331
73333
73335
73337
73339
73351
73353
73355
73357
73359
73371
73373
73375
73377
73379
73391
73393
73395
73397
73399
73511
73513
73515
73517
73519
73531
73533
73535
73537
73539
73551
73553
73555
73557
73559
73571
73573
73575
73577
73579
73591
73593
73595
73597
73599
73711
73713
73715
73717
73719
73731
73733
73735
73737
73739
73751
73753
73755
73757
73759
73771
73773
73775
73777
73779
73791
73793
73795
73797
73799
73911
73913
73915
73917
73919
73931
73933
73935
73937
73939
73951
73953
73955
73957
73959
73971
73973
73975
73977
73979
73991
73993
73995
73997
73999
75111
75113
75115
75117
75119
75131
75133
75135
75137
75139
75151
75153
75155
75157
75159
75171
75173
75175
75177
75179
75191
75193
75195
75197
75199
75311
75313
75315
75317
75319
75331
75333
75335
75337
75339
75351
75353
75355
75357
75359
75371
75373
75375
75377
75379
75391
75393
75395
75397
75399
75511
75513
75515
75517
75519
75531
75533
75535
75537
75539
75551
75553
75555
75557
75559
75571
75573
75575
75577
75579
75591
75593
75595
75597
75599
75711
75713
75715
75717
75719
75731
75733
75735
75737
75739
75751
75753
75755
75757
75759
75771
75773
75775
75777
75779
75791
75793
75795
75797
75799
75911
75913
75915
75917
75919
75931
75933
75935
75937
75939
75951
75953
75955
75957
75959
75971
75973
75975
75977
75979
75991
75993
75995
75997
75999
77111
77113
77115
77117
77119
77131
77133
77135
77137
77139
77151
77153
77155
77157
77159
77171
77173
77175
77177
77179
77191
77193
77195
77197
77199
77311
77313
77315
77317
77319
77331
77333
77335
77337
77339
77351
77353
77355
77357
77359
77371
77373
77375
77377
77379
77391
77393
77395
77397
77399
77511
77513
77515
77517
77519
77531
77533
77535
77537
77539
77551
77553
77555
77557
77559
77571
77573
77575
77577
77579
77591
77593
77595
77597
77599
77711
77713
77715
77717
77719
77731
77733
77735
77737
77739
77751
77753
77755
77757
77759
77771
77773
77775
77777
77779
77791
77793
77795
77797
77799
77911
77913
77915
77917
77919
77931
77933
77935
77937
77939
77951
77953
77955
77957
77959
77971
77973
77975
77977
77979
77991
77993
77995
77997
77999
79111
79113
79115
79117
79119
79131
79133
79135
79137
79139
79151
79153
79155
79157
79159
79171
79173
79175
79177
79179
79191
79193
79195
79197
79199
79311
79313
79315
79317
79319
79331
79333
79335
79337
79339
79351
79353
79355
79357
79359
79371
79373
79375
79377
79379
79391
79393
79395
79397
79399
79511
79513
79515
79517
79519
79531
79533
79535
79537
79539
79551
79553
79555
79557
79559
79571
79573
79575
79577
79579
79591
79593
79595
79597
79599
79711
79713
79715
79717
79719
79731
79733
79735
79737
79739
79751
79753
79755
79757
79759
79771
79773
79775
79777
79779
79791
79793
79795
79797
79799
79911
79913
79915
79917
79919
79931
79933
79935
79937
79939
79951
79953
79955
79957
79959
79971
79973
79975
79977
79979
79991
79993
79995
79997
79999
91111
91113
91115
91117
91119
91131
91133
91135
91137
91139
91151
91153
91155
91157
91159
91171
91173
91175
91177
91179
91191
91193
91195
91197
91199
91311
91313
91315
91317
91319
91331
91333
91335
91337
91339
91351
91353
91355
91357
91359
91371
91373
91375
91377
91379
91391
91393
91395
91397
91399
91511
91513
91515
91517
91519
91531
91533
91535
91537
91539
91551
91553
91555
91557
91559
91571
91573
91575
91577
91579
91591
91593
91595
91597
91599
91711
91713
91715
91717
91719
91731
91733
91735
91737
91739
91751
91753
91755
91757
91759
91771
91773
91775
91777
91779
91791
91793
91795
91797
91799
91911
91913
91915
91917
91919
91931
91933
91935
91937
91939
91951
91953
91955
91957
91959
91971
91973
91975
91977
91979
91991
91993
91995
91997
91999
93111
93113
93115
93117
93119
93131
93133
93135
93137
93139
93151
93153
93155
93157
93159
93171
93173
93175
93177
93179
93191
93193
93195
93197
93199
93311
93313
93315
93317
93319
93331
93333
93335
93337
93339
93351
93353
93355
93357
93359
93371
93373
93375
93377
93379
93391
93393
93395
93397
93399
93511
93513
93515
93517
93519
93531
93533
93535
93537
93539
93551
93553
93555
93557
93559
93571
93573
93575
93577
93579
93591
93593
93595
93597
93599
93711
93713
93715
93717
93719
93731
93733
93735
93737
93739
93751
93753
93755
93757
93759
93771
93773
93775
93777
93779
93791
93793
93795
93797
93799
93911
93913
93915
93917
93919
93931
93933
93935
93937
93939
93951
93953
93955
93957
93959
93971
93973
93975
93977
93979
93991
93993
93995
93997
93999
95111
95113
95115
95117
95119
95131
95133
95135
95137
95139
95151
95153
95155
95157
95159
95171
95173
95175
95177
95179
95191
95193
95195
95197
95199
95311
95313
95315
95317
95319
95331
95333
95335
95337
95339
95351
95353
95355
95357
95359
95371
95373
95375
95377
95379
95391
95393
95395
95397
95399
95511
95513
95515
95517
95519
95531
95533
95535
95537
95539
95551
95553
95555
95557
95559
95571
95573
95575
95577
95579
95591
95593
95595
95597
95599
95711
95713
95715
95717
95719
95731
95733
95735
95737
95739
95751
95753
95755
95757
95759
95771
95773
95775
95777
95779
95791
95793
95795
95797
95799
95911
95913
95915
95917
95919
95931
95933
95935
95937
95939
95951
95953
95955
95957
95959
95971
95973
95975
95977
95979
95991
95993
95995
95997
95999
97111
97113
97115
97117
97119
97131
97133
97135
97137
97139
97151
97153
97155
97157
97159
97171
97173
97175
97177
97179
97191
97193
97195
97197
97199
97311
97313
97315
97317
97319
97331
97333
97335
97337
97339
97351
97353
97355
97357
97359
97371
97373
97375
97377
97379
97391
97393
97395
97397
97399
97511
97513
97515
97517
97519
97531
97533
97535
97537
97539
97551
97553
97555
97557
97559
97571
97573
97575
97577
97579
97591
97593
97595
97597
97599
97711
97713
97715
97717
97719
97731
97733
97735
97737
97739
97751
97753
97755
97757
97759
97771
97773
97775
97777
97779
97791
97793
97795
97797
97799
97911
97913
97915
97917
97919
97931
97933
97935
97937
97939
97951
97953
97955
97957
97959
97971
97973
97975
97977
97979
97991
97993
97995
97997
97999
99111
99113
99115
99117
99119
99131
99133
99135
99137
99139
99151
99153
99155
99157
99159
99171
99173
99175
99177
99179
99191
99193
99195
99197
99199
99311
99313
99315
99317
99319
99331
99333
99335
99337
99339
99351
99353
99355
99357
99359
99371
99373
99375
99377
99379
99391
99393
99395
99397
99399
99511
99513
99515
99517
99519
99531
99533
99535
99537
99539
99551
99553
99555
99557
99559
99571
99573
99575
99577
99579
99591
99593
99595
99597
99599
99711
99713
99715
99717
99719
99731
99733
99735
99737
99739
99751
99753
99755
99757
99759
99771
99773
99775
99777
99779
99791
99793
99795
99797
99799
99911
99913
99915
99917
99919
99931
99933
99935
99937
99939
99951
99953
99955
99957
99959
99971
99973
99975
99977
99979
99991
99993
99995
99997
99999



[/CODE]


You can copy and paste into notepad or wordpad or MS Word and save as a text file.

pepi37 2017-05-23 00:18

Perfect!
Thanks
That is what I need!

science_man_88 2017-05-23 00:37

[QUOTE=pepi37;459561]Perfect!
Thanks
That is what I need![/QUOTE]

[url]http://www.mathsisfun.com/combinatorics/combinations-permutations.html[/url] suggest that since you can select n-1 things each time ( the one's that aren't the same as the one before) it would be (n-1)^r for the normal case of length r. edit: or rather [TEX]n (n-1)^{(r-1)}[/TEX]

a1call 2017-05-23 01:01

1 Attachment(s)
The file is too long for the code tag.
Let's see if the attachment works.

pepi37 2017-05-23 01:14

[QUOTE=a1call;459565]The file is too long for the code tag.
Let's see if the attachment works.[/QUOTE]

Thanks once more time. Now I can play with those numbers :-)

a1call 2017-05-23 01:17

[QUOTE=pepi37;459566]Thanks once more time. Now I can play with those numbers :-)[/QUOTE]
My Pleasure [B]pepi37[/B],
Anytime.:smile:

CRGreathouse 2017-05-23 02:29

[QUOTE=a1call;459555]Not most efficient code but it should work.

[CODE]theCounter = 19
theOldString = ""
forstep(i1=1,9,2,{
forstep(i2=1,9,2,
forstep(i3=1,9,2,
forstep(i4=1,9,2,
forstep(i5=1,9,2,
theString = Str(i1,i2,i3,i4,i5) ;
if (theOldString != theString ,
theOldString = theString;
print(theString );
);
theCounter = theCounter -1;
if (theCounter <1, next(19););
);
);
);
);
})

[/CODE][/QUOTE]

You can do

[code]forvec(v=vector(4,i,[1,5]), print(fromdigits(apply(n->2*n-1, v))))[/code]

where forvec does the work of the five loops, apply converts 1..5 to 1,3,5,7,9, and fromdigits converts [1,3,5,7] to 1357. (The base is 10 unless you give a different base as a second argument.)

a1call 2017-05-23 02:48

I have never been able to make forvec work before. I find the documentation vague without any examples. I will come back to your example next time I need it.
Apply and fromdigits is news to me.
For 0,1,3,5,7,9 , wouldn't it be easier to include them in the vector rather than formulate a conversion?
Thank you for code.

CRGreathouse 2017-05-23 03:31

[QUOTE=a1call;459572]I have never been able to make forvec work before. I find the documentation vague without any examples.[/QUOTE]

Yes, the forvec documentation is bad. :down:

The basic idea is that you can replace a collection of nested for loops like this:

[CODE]for(i1=start1,end1,
for(i2=start2,end2,
...
[i1, i2, ...]
...
)
)[/CODE]

with

[code]forvec(v=[ [start1,end1], [start2,end2], ...],
v
)[/code]

There is an optional final argument that if set to 1 gives only weakly increasing vectors ([1, 1, 2] but not [2, 1, 2]), and if set to 2 gives only strictly increasing vectors ([1, 2, 3] but not [1, 2, 2]). So you can replace
[code]for(a=0,6, for(b=a+1,7, for(c=b+1,8, for(d=c+1,9, f(a,b,c,d)))))[/code]
with
[code]forvec(v=vector(4,i,[0,9]), f(v[1],v[2],v[3],v[4]), 2)[/code]
which can be abbreviated
[code]forvec(v=vector(4,i,[0,9]), call(f,v), 2)[/code]

[QUOTE=a1call;459572]For 0,1,3,5,7,9 , wouldn't it be easier to include them in the vector rather than formulate a conversion?[/QUOTE]

For me it would be easier and more natural to use a vector rather than gluing them together as a decimal number, but I wanted to match your output.

[QUOTE=a1call;459572]Apply and fromdigits is news to me.[/QUOTE]

fromdigits is boring -- fromdigits([1, 2, 3]) is 123 and fromdigits([1, 0, 1], 2) is 5 (binary).

apply is great, I use it all the time. apply(f, [1, 2, 3]) returns [f(1), f(2), f(3)], where f is some function. (Of course the function is computed, it doesn't actually write "f(1)" unless that's what the function does.) apply(cos, [0, Pi/2, Pi]) gives approximately [1, 0, -1].

In my example I used a 'lambda' type expression to define an anonymous function. Instead I could have written
[code]doubleMinusOne(n)=2*n-1;
forvec(v=vector(4,i,[1,5]), print(fromdigits(apply(doubleMinusOne, v))))[/code]
but this way I don't have to think up a name for this little function that I'm only using in this one spot.

CRGreathouse 2017-05-23 03:33

[QUOTE=CRGreathouse;459574]Yes, the forvec documentation is bad. :down:[/QUOTE]

Also, I think scienceman88 uses forvec a lot, he might have more useful examples if mine don't help. :smile:

a1call 2017-05-23 04:11

Thank you for the very detailed explanation [B]CRG[/B]. Much appreciated.:smile:

science_man_88 2017-05-23 10:27

[QUOTE=CRGreathouse;459575]Also, I think scienceman88 uses forvec a lot, he might have more useful examples if mine don't help. :smile:[/QUOTE]

I actually don't even use fold as much as I should I did implement Jordan's totient function at one point ( see my pastebin).


All times are UTC. The time now is 15:52.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.