10 ' ファイル名:mn_final.ub
20 ' 作成年月日:1997/02/24
30 ' print=print+"mn_final.txt"
40 ' m/p=1/a+1/b+1/c
50 ' p/m<a<=3p/m , 1+int(p/m)<=a<=int(3p/m)
60 ' m/p-1/a=(ma-p)/pa=d/e
70 for M=4 to 7
80 for I=1 to 25:P=prm(I):if M/P>3 then 280
90 for A=1+int(P/M) to int(3*P/M)
100 D=M*A-P:E=P*A:reduce D,E
110 ' d/e=1/b+1/c
120 ' max{a,1+int(e/d)}<=b<=int(2e/d)
130 ' d/e-1/b=(db-e)/eb
140 for B=max(A,1+int(E/D)) to int(2*E/D)
150 if or{A=B,B=C} then 260
160 if B@P=0 then 260
170 if (E*B)@(D*B-E)>0 then 260
180 C=(E*B)\(D*B-E)
190 ' print M,P,A,B,C
200 ' m/p = 1/a + 1/b + 1/c
210 ' m/A = 1/hC + 1/jBC + 1/eAB
220 ' A : Van-Vb
230 ' B : Vcn-d
240 ' C : un-v
250 R=fnMain(M,P,A,B,C)
260 next B
270 next A
280 next I
290 next M
300 end
310 ' m/(an-b)-1/e(cn-d)(an-b)
320 ' = {me(cn-d)-1}/e(an-b)(cn-d)
330 ' = {mecn-(med+1)}/e(an-b)(cn-d)
340 ' bmec=a(med+1) <=> me(bc-ad)=a <=> m|a => a=mk
350 ' e(bc-ad)=k , e|k
360 ' = c/k(cn-d) , reduce(c,k)=p,q
370 ' m/(Van-Vb) : m/p
380 ' 1/h(un-v) : 1/a
390 ' 1/j(un-v)(Vcn-d) : 1/b
400 ' 1/e(Van-Vb)(Vcn-d) : 1/c
410 fnMain(M,P,A,B,C)
420 local D,E,F,G,H,I,J,K,L
430 local Va,Vb,Vc
440 '
450 Z=0
460 for Va=M to M*100 step M:K=Va\M
470 if Va<P then Vb=Va-P@Va else Vb=Va-P
480 if gcd(Va,Vb)>1 then 600
490 Vn=(P+Vb)\Va
500 for E=1 to K:if K@E>0 then 590 else L=K\E
510 for D=1 to Va*10
520 if (L+Va*D)@Vb>0 then 580
530 Vc=(L+Va*D)\Vb:if gcd(Vc,D)>1 then 580
540 if E*(Va*Vn-Vb)*(Vc*Vn-D)<>C then 580
550 F=gcd(Vc,K)
560 gosub 680:' -1/(fn-g)
570 if Z=1 then cancel for:cancel for:cancel for:goto 610
580 next D
590 next E
600 next Va
610 return(0)
620 ' c/k(cn-d)-1/(fn-g)
630 ' = {c(fn-g)-k(cn-d)}/k(cn-d)(fn-g)
640 ' = {(cf-kc)n-(cg-kd)}/k(cn-d)(fn-g)
650 ' cf-kc=0 => f=k
660 ' kd-cg>0 , (kd-cg)|k(f,g)=kh
670 ' gcd(f,g)=h , u=f\h , v=g\h
680 ' c/k : zoudai
690 ' i : gensyou
700 ' if=k*d-c*g>0 , c<k*d/g<=k*d
710 for G=1 to K:H=gcd(K,G):I=K*D-Vc*G
720 if I<=0 then cancel for:return
730 if K*H@I>0 then 770
740 U=K\H:V=G\H:J=K*H\I
750 gosub 800:' pretty print
760 if Z=1 then cancel for:goto 780
770 next G
780 return
790 ' number print
800 N=1
810 while Va*N-Vb<=P*5
820 W=Va*N-Vb:if prmdiv(W)<W then 930
830 X=Vc*N-D:Y=U*N-V
840 if W<>P then 930
850 if H*Y<>A then 930
860 if J*X*Y<>B then 930
870 if E*W*X<>C then 930
880 print cutspc(str(M));",";cutspc(str(W));",";cutspc(str(H*Y));",";
890 print cutspc(str(J*X*Y));",";cutspc(str(E*W*X));",";cutspc(str(N));
900 print ",";
910 Z=1:goto 950
920 ' print M,W,H*Y,J*X*Y,E*W*X,N:Z=1:goto 900
930 inc N
940 wend:return
950 gosub 970:Z=1:return
960 ' pretty print (siki print) m,A,hC,jBC,eAB
970 A$=str(Va)+"n-"+str(Vb):B$=str(Vc)+"n-"+str(D)
980 C$=str(U)+"n-"+str(V)
990 ' m
1000 ' print cutspc(str(M));",";
1010 ' A,
1020 O$=A$:print cutspc(O$);",";
1030 ' hC=h(un-v)
1040 if H>1 then O$=str(H)+"(" else O$=""
1050 O$=O$+C$:print cutspc(O$);
1060 if H>1 then print "),"; else print ",";
1070 ' jBC
1080 if J>1 then O$=str(J) else O$=""
1090 O$=O$+"("+B$+")("+C$+")":print cutspc(O$);",";
1100 ' eAB
1110 if E>1 then O$=str(E) else O$=""
1120 O$=O$+"("+A$+")("+B$+")":print cutspc(O$)
1130 Z=1:return
このプログラムを実行すると、
4,3,1,4,12,1,8n-5,2n-1,2(5n-3)(2n-1),2(8n-5)(5n-3)
4,5,2,4,20,1,16n-11,2(2n-1),4(3n-2)(2n-1),4(16n-11)(3n-2)
4,7,2,15,210,1,16n-9,2(2n-1),(34n-19)(2n-1),2(16n-9)(34n-19)
……
というように、個別解とそれを生成する恒等式が順に表示される。
m:4,5,6,7
p:100以下の素数
についての実行結果は以下のとおり。これが最終結果である。
| 前 | この章の目次 | 次 |
|---|