home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 34 / 034.d81 / permutations (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  7KB  |  59 lines

  1. 5 gosub60100
  2. 6 clr:dim g$(6)
  3. 10 poke53280,3:poke53281,5
  4. 100 print"[144][147]          loadstar presents:"
  5. 105 print"  permutations & combinations - sander"
  6. 110 print"  this shows the number of possible"
  7. 120 print"  permutations and combinations of"
  8. 130 print"  numbers that you input."
  9. 135 print"enter q to quit."
  10. 140 print"how many objects:";:gosub500:n=val(a$)
  11. 141 ifa$="q"ora$="[209]"then260
  12. 142 ifn<1thenprint"number must be greater than 0.":goto135
  13. 145 print"enter q to quit."
  14. 150 print"taken how many at a time:";:gosub500:d=val(a$):ifa$="q"then260
  15. 152 ifa$="q"ora$="[209]"then260
  16. 155 ifd<1thenprint"number must be greater than 0.":goto145
  17. 160 ifd>nthenprint"too many!":goto140
  18. 170 p=1:c=1
  19. 180 forj=n-d+1ton:if1.7e38/j>=pthen200
  20. 190 print"> 1.7e38 permutations!!":goto230
  21. 200 p=p*j:next:fork=2tod:c=c*k:next
  22. 210 print" number of permutations =";p
  23. 220 print" number of combinations =";p/c:print
  24. 230 print"want to do another? (y/n)"
  25. 240 geta$:ifa$<>"y"anda$<>"n"ora$="[217]"ora$="[206]"then240
  26. 250 ifa$="y"ora$="[217]"then10
  27. 255 goto265
  28. 260 gosub 61000:run6
  29. 265 open15,8,15,"r0:hello connect=hello connect":input#15,er:close15
  30. 270 print"[147]";:ifer<>63thenend
  31. 280 load"hello connect",8
  32. 500 print"[164]";:fora=1to6:g$(a)=""
  33. 510 geta$:ifa$=""then510
  34. 520 ifa$=chr$(13)then570
  35. 530 if(a$=chr$(20))and(a>1)thenprint"[157][157]  [157][157][164]";:a=a-1:g$(a)="":goto510
  36. 532 if(a=6)then510
  37. 535 if(a$="[209]")thena$="q"
  38. 540 if(a$="q")or(a$="-")or(a$="+")or(a$=".")then560
  39. 550 if(a$<"0")or(a$>"9")then510
  40. 560 print"[157]"a$"[164]";:g$(a)=a$:next
  41. 570 print"[157] ":a$=""
  42. 580 forb=1toa-1:a$=a$+g$(b):next:return
  43. 60100 poke53280,6:poke53281,6:print"[147]"chr$(142);
  44. 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]";
  45. 60120 fora=1to23:print"[221]"spc(38)"[221]";:next
  46. 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]";
  47. 60140 print"          loadstar presents:"
  48. 60150 print"[153]             permutations"
  49. 60160 print"          by louis f. sander"
  50. 60165 print"           (c)opyright 1987"
  51. 60170 print"[158]       press any key to continue"
  52. 60180 poke198,.:wait 198,1:geta$:return
  53. 61000 rem quit for sure
  54. 61010 print"[147]are you sure you want to quit (y/n)?"
  55. 61020 poke198,0:wait198,1:geta$
  56. 61030 ifa$="y"ora$="[217]"then265
  57. 61040 ifa$="n"ora$="[206]"thenreturn
  58. 61050 goto61020
  59.