Code : Tout sélectionner
10 FAST:SCNCLR
20 PRINT "CALCUL DE LA FACTORIELLE"
30 PRINT "------------------------"
40 DIM FA(500)
50 INPUT "NB=";NB
60 FA(1)=1:B%=1:T=TI
70 FOR I=1 TO NB:FOR J=1 TO B%:RL=FA(J)*I+RT:RT=INT(RL/1000000):FA(J)=RL-1
000000*RT:NEXT J:IF RT<>0 THEN B%=B%+1:FA(B%)=RT:RT=0
80 NEXT I
155 T=(TI-T)/60
160 PRINT:PRINT "FACTORIELLE DE";NB;"="
165 PRINT FA(B%);
166 P%=1
190 FOR I=B%-1 TO 1 STEP -1
200 WN$=STR$(FA(I)):GOSUB 300:PRINT WN$;" ";
205 P%=P%+1:IF P%>9 THEN PRINT:P%=0
210 NEXT I
220 PRINT:PRINT "calcul en ";t; "sec";t/60;"min"
230 print "nbr tableau=";b%
240 print "nbr chiffre=";(b%-1)*6+len(str$(fa(b%)))-1
250 end
300 wn$=right$(wn$,len(wn$)-1)
310 if len(wn$)=6 then 399
320 for j=1 to 6-len(wn$)
330 wn$="0"+wn$
340 next j
399 return
1000 print i,b,rt;
1001 for w=1 to b:print fa(w);:next w:print:getkey a$
1010 return