Duffinian numbers: Difference between revisions
Content deleted Content added
Not a robot (talk | contribs) add Draco |
Not a robot (talk | contribs) Add MAD |
||
Line 1,378: | Line 1,378: | ||
8449 8450 8451 |
8449 8450 8451 |
||
</pre> |
</pre> |
||
=={{header|MAD}}== |
|||
<syntaxhighlight lang="mad"> NORMAL MODE IS INTEGER |
|||
DIMENSION SIGMA(10000),OUTROW(10) |
|||
INTERNAL FUNCTION(AA,BB) |
|||
ENTRY TO GCD. |
|||
A = AA |
|||
B = BB |
|||
STEP WHENEVER A.E.B, FUNCTION RETURN A |
|||
WHENEVER A.G.B, A = A-B |
|||
WHENEVER A.L.B, B = B-A |
|||
TRANSFER TO STEP |
|||
END OF FUNCTION |
|||
INTERNAL FUNCTION(N) |
|||
ENTRY TO DUFF. |
|||
SIG = SIGMA(N) |
|||
FUNCTION RETURN SIG.G.N+1 .AND. GCD.(N,SIG).E.1 |
|||
END OF FUNCTION |
|||
INTERNAL FUNCTION(N) |
|||
ENTRY TO TRIP. |
|||
FUNCTION RETURN DUFF.(N) .AND. |
|||
0 DUFF.(N+1) .AND. DUFF.(N+2) |
|||
END OF FUNCTION |
|||
THROUGH SZERO, FOR I=1, 1, I.G.10000 |
|||
SZERO SIGMA(I) = 0 |
|||
THROUGH SCALC, FOR I=1, 1, I.G.10000 |
|||
THROUGH SCALC, FOR J=I, I, J.G.10000 |
|||
SCALC SIGMA(J) = SIGMA(J) + I |
|||
PRINT COMMENT $ FIRST 50 DUFFINIAN NUMBERS$ |
|||
CAND = 0 |
|||
THROUGH DUFROW, FOR R=0, 1, R.GE.5 |
|||
THROUGH DUFCOL, FOR C=0, 1, C.GE.10 |
|||
SCHDUF THROUGH SCHDUF, FOR CAND=CAND+1, 1, DUFF.(CAND) |
|||
DUFCOL OUTROW(C) = CAND |
|||
DUFROW PRINT FORMAT ROWFMT,OUTROW(0),OUTROW(1),OUTROW(2), |
|||
0 OUTROW(3),OUTROW(4),OUTROW(5),OUTROW(6), |
|||
1 OUTROW(7),OUTROW(8),OUTROW(9) |
|||
PRINT COMMENT $ $ |
|||
PRINT COMMENT $ FIRST 15 DUFFINIAN TRIPLETS$ |
|||
CAND = 0 |
|||
THROUGH DUFTRI, FOR S=0, 1, S.GE.15 |
|||
SCHTRP THROUGH SCHTRP, FOR CAND=CAND+1, 1, TRIP.(CAND) |
|||
DUFTRI PRINT FORMAT TRIFMT,CAND,CAND+1,CAND+2 |
|||
VECTOR VALUES ROWFMT = $10(I5)*$ |
|||
VECTOR VALUES TRIFMT = $3(I7)*$ |
|||
END OF PROGRAM</syntaxhighlight> |
|||
{{out}} |
|||
<pre>FIRST 50 DUFFINIAN NUMBERS |
|||
4 8 9 16 21 25 27 32 35 36 |
|||
39 49 50 55 57 63 64 65 75 77 |
|||
81 85 93 98 100 111 115 119 121 125 |
|||
128 129 133 143 144 155 161 169 171 175 |
|||
183 185 187 189 201 203 205 209 215 217 |
|||
FIRST 15 DUFFINIAN TRIPLETS |
|||
63 64 65 |
|||
323 324 325 |
|||
511 512 513 |
|||
721 722 723 |
|||
899 900 901 |
|||
1443 1444 1445 |
|||
2303 2304 2305 |
|||
2449 2450 2451 |
|||
3599 3600 3601 |
|||
3871 3872 3873 |
|||
5183 5184 5185 |
|||
5617 5618 5619 |
|||
6049 6050 6051 |
|||
6399 6400 6401 |
|||
8449 8450 8451</pre> |
|||
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
=={{header|Mathematica}}/{{header|Wolfram Language}}== |