home *** CD-ROM | disk | FTP | other *** search
/ Tiger Disk 24 / Tiger_Disk_024_19xx_Tiger-Crew-Disk_de_Side_A.d64 / prim-fak-zerleg. (.txt) < prev    next >
Commodore BASIC  |  2023-02-26  |  2KB  |  62 lines

  1. 1 poke53272,23:poke53280,6:print"[147]";:poke53265,11
  2. 2 print"[208]rogramm: prim-fak-zerleg":gosub47
  3. 3 print"[198]unktion: [208]rogramm zerlegt die einge-"
  4. 4 print"          gebene [218]ahl in ihre [208]rim-"
  5. 5 print"          faktoren.":gosub47
  6. 6 print"[197]ingabe:  n, die zu zerlegende [218]ahl":gosub47
  7. 7 print"[193]usgabe:  [208]rimfaktoren":gosub47
  8. 8 print"[194]eispiel:"
  9. 9 print"180 = 2 ^ 2 * 3 ^ 2 * 5":gosub47
  10. 10 print"[194]itte druecken [211]ie eine [212]aste!";:poke53265,27
  11. 11 geta$:ifa$=""then11
  12. 12 dimt(100),at(100),aa(100)
  13. 13 print"[147][194]itte geben [211]ie ein:"
  14. 14 input"n = ";n$:n=val(n$)
  15. 15 h=n
  16. 16 print"[194]itte warten!"
  17. 17 ifn<>int(n)thengosub60
  18. 18 h=n
  19. 19 ifn<=0thenprint"[206] muss groesser als [206]ull sein!":print:goto13
  20. 20 ifn<4theni=0:goto28
  21. 21 i=0:t=2:gosub48:t=3
  22. 22 gosub48
  23. 23 t=t+2
  24. 24 ift<(sqr(n)+1)then22
  25. 25 ifn=1then28
  26. 26 ifn=hthen28
  27. 27 i=i+1:t(i)=n
  28. 28 ifi<>0then30
  29. 29 print"[157]";h;"ist eine [208]rimzahl.":gosub50:goto13
  30. 30 imax=i:t(imax+1)=0
  31. 31 j=1:i=1
  32. 32 at(j)=t(i):aa(j)=1
  33. 33 ifi=imaxthen36
  34. 34 ift(i)=t(i+1)thenaa(j)=aa(j)+1:i=i+1:goto33
  35. 35 j=j+1:i=i+1:goto32
  36. 36 n=1
  37. 37 forx=1toj:n=n*at(x)^aa(x):next
  38. 38 ifint(h)=int(n)then41
  39. 39 print"[208]rogramm liefert falsche [218]erlegung!"
  40. 40 print"[193]lgorithmus pruefen!!!"
  41. 41 print"[157]";h;"=";
  42. 42 x=1
  43. 43 printat(x);
  44. 44 ifaa(x)>1thenprint"^";aa(x);
  45. 45 ifx<jthenprint"*";:x=x+1:goto43
  46. 46 print"":gosub50:goto13
  47. 47 forx=1to40:print"-";:next:return
  48. 48 if(n/t)<>int(n/t)thenreturn
  49. 49 i=i+1:t(i)=t:n=n/t:goto48
  50. 50 gosub47
  51. 51 print"[215]ollen [211]ie eine weitere [218]ahl zerlegen?"
  52. 52 print"[215]enn nein, druecken [211]ie '[206]', ansonsten"
  53. 53 print"eine beliebige andere [212]aste!";
  54. 54 geta$:ifa$=""then54
  55. 55 ifa$="n"then57
  56. 56 n=0:return
  57. 57 poke53280,14:print"[147]";
  58. 58 print"[208]rogramm 'prim-fak-zerleg' wurde auf"
  59. 59 print"[201]hren [215]unsch abgebrochen!":end
  60. 60 n=int(n):h=n
  61. 61 print"[206] wurde in eine ganze [218]ahl verwandelt!":return
  62.