Data update
This commit is contained in:
parent
8f05c7136f
commit
0bf4da02c3
82 changed files with 2194 additions and 118 deletions
27
Task/Totient-function/BASIC/totient-function.basic
Normal file
27
Task/Totient-function/BASIC/totient-function.basic
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
10 DEFINT A-Z: DIM B$(2): B$(0)="No": B$(1)="Yes"
|
||||
20 PRINT " N Totient Prime"
|
||||
30 FOR N=1 TO 25
|
||||
40 GOSUB 200
|
||||
50 P=-(T=N-1)
|
||||
60 C=C+P
|
||||
70 PRINT USING "## ####### \ \";N;T;B$(P)
|
||||
80 NEXT N
|
||||
90 F$="Number of primes up to ######: ####"
|
||||
100 PRINT USING F$;25;C
|
||||
110 FOR N=26 TO 10000
|
||||
120 GOSUB 200
|
||||
130 C=C-(T=N-1)
|
||||
140 IF N=100 OR N=1000 OR N=10000 THEN PRINT USING F$;N;C
|
||||
150 NEXT N
|
||||
160 END
|
||||
200 REM T = TOTIENT(N)
|
||||
210 T=N: Z=N
|
||||
220 I=2: GOSUB 270
|
||||
230 I=3
|
||||
240 IF I*I<=Z THEN GOSUB 270: I=I+2: GOTO 240
|
||||
250 IF Z>1 THEN T=T-T\Z
|
||||
260 RETURN
|
||||
270 IF Z MOD I<>0 THEN RETURN
|
||||
280 IF Z MOD I=0 THEN Z = Z\I: GOTO 280
|
||||
290 T = T-T\I
|
||||
300 RETURN
|
||||
Loading…
Add table
Add a link
Reference in a new issue