home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 34
/
034.d81
/
permutations
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
7KB
|
59 lines
5 gosub60100
6 clr:dim g$(6)
10 poke53280,3:poke53281,5
100 print"[144][147] loadstar presents:"
105 print" permutations & combinations - sander"
110 print" this shows the number of possible"
120 print" permutations and combinations of"
130 print" numbers that you input."
135 print"enter q to quit."
140 print"how many objects:";:gosub500:n=val(a$)
141 ifa$="q"ora$="[209]"then260
142 ifn<1thenprint"number must be greater than 0.":goto135
145 print"enter q to quit."
150 print"taken how many at a time:";:gosub500:d=val(a$):ifa$="q"then260
152 ifa$="q"ora$="[209]"then260
155 ifd<1thenprint"number must be greater than 0.":goto145
160 ifd>nthenprint"too many!":goto140
170 p=1:c=1
180 forj=n-d+1ton:if1.7e38/j>=pthen200
190 print"> 1.7e38 permutations!!":goto230
200 p=p*j:next:fork=2tod:c=c*k:next
210 print" number of permutations =";p
220 print" number of combinations =";p/c:print
230 print"want to do another? (y/n)"
240 geta$:ifa$<>"y"anda$<>"n"ora$="[217]"ora$="[206]"then240
250 ifa$="y"ora$="[217]"then10
255 goto265
260 gosub 61000:run6
265 open15,8,15,"r0:hello connect=hello connect":input#15,er:close15
270 print"[147]";:ifer<>63thenend
280 load"hello connect",8
500 print"[164]";:fora=1to6:g$(a)=""
510 geta$:ifa$=""then510
520 ifa$=chr$(13)then570
530 if(a$=chr$(20))and(a>1)thenprint"[157][157] [157][157][164]";:a=a-1:g$(a)="":goto510
532 if(a=6)then510
535 if(a$="[209]")thena$="q"
540 if(a$="q")or(a$="-")or(a$="+")or(a$=".")then560
550 if(a$<"0")or(a$>"9")then510
560 print"[157]"a$"[164]";:g$(a)=a$:next
570 print"[157] ":a$=""
580 forb=1toa-1:a$=a$+g$(b):next:return
60100 poke53280,6:poke53281,6:print"[147]"chr$(142);
60110 print"[159][176][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][174]";
60120 fora=1to23:print"[221]"spc(38)"[221]";:next
60130 print"[173][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][189][157][148][192]";
60140 print" loadstar presents:"
60150 print"[153] permutations"
60160 print" by louis f. sander"
60165 print" (c)opyright 1987"
60170 print"[158] press any key to continue"
60180 poke198,.:wait 198,1:geta$:return
61000 rem quit for sure
61010 print"[147]are you sure you want to quit (y/n)?"
61020 poke198,0:wait198,1:geta$
61030 ifa$="y"ora$="[217]"then265
61040 ifa$="n"ora$="[206]"thenreturn
61050 goto61020