|
http://ja.wikipedia.org/wiki/フィボナッチ数
OPTION ARITHMETIC DECIMAL_HIGH
DIM A(0 TO 200)
LET SQR2=SQR(2)
LET A(1)=1
LET A(2)=2
FOR N=3 TO 200
LET A(N)=2*A(N-1)+A(N-2)
PRINT A(N) !'ベル数
!'PRINT INT(((1+SQR2)^N-(1-SQR2)^N)/2/SQR2+.5)
NEXT N
PRINT
MAT A=ZER
LET A(2)=1
FOR N=0 TO 197
LET A(N+3)=A(N)+A(N+1)+A(N+2)
PRINT A(N+3) !'トリボナッチ数
NEXT N
PRINT
MAT A=ZER
LET A(3)=1
FOR N=0 TO 196
LET A(N+4)=A(N)+A(N+1)+A(N+2)+A(N+3)
PRINT A(N+4) !'テトラナッチ数
NEXT N
END
----------------------------------------------------------------------------
OPTION ARITHMETIC DECIMAL_HIGH
LET A=1
LET B=1
LET S=2
FOR I=1 TO 5000
IF MAXNUM<A+B THEN EXIT FOR
LET C=A+B
LET S=S+1/C
LET A=B
LET B=C
NEXT I
PRINT S !'フィボナッチ数の逆数の総和
END
----------------------------------------------------------------------------
OPTION ARITHMETIC DECIMAL_HIGH
LET C=1
FOR K=0 TO 100
PRINT K;":";C
LET C=C*(4-6/(K+2))
NEXT K
PRINT
LET C=1
FOR N=1 TO 100
PRINT N;":";C
LET C=C*2*(2*N+1)/(N+2)
NEXT N
PRINT
LET S=1
FOR N=1 TO 100
PRINT FACT(2*N)/FACT(N+1)/FACT(N)
LET S=S*(2*N)*(2*N-1)/N/(N+1)
PRINT N;":";S
PRINT N;":";COMB(2*N,N)-COMB(2*N,N+1)
PRINT
NEXT N
PRINT
DIM A(0 TO 100)
LET A(0)=1
FOR N=1 TO 100
FOR K=0 TO N-1
LET A(N)=A(N)+A(K)*A(N-K-1)
NEXT K
PRINT N;":";A(N)
NEXT N
END
----------------------------------------------------------------------------
OPTION ARITHMETIC DECIMAL_HIGH
LET XX=1
DO
LET X=XX
LET XX=X-F(X)/DF(X)
LOOP UNTIL ABS(X-XX)<EPS(0)
PRINT XX
END
EXTERNAL FUNCTION F(X)
OPTION ARITHMETIC DECIMAL_HIGH
LET F=X*X*X-X-1
END FUNCTION
EXTERNAL FUNCTION DF(X)
OPTION ARITHMETIC DECIMAL_HIGH
LET DF=3*X*X-1
END FUNCTION
----------------------------------------------------------------------------
OPTION ARITHMETIC DECIMAL_HIGH
LET T=1/5
LET XX=T
DO
LET X=XX
LET XX=X+(X-X*X*X*T)/2
LOOP UNTIL X=XX
LET XX=(1+X)/2
PRINT XX
PRINT 1+1/XX
PRINT 2*LCOS(PI/5)
PRINT 2*LSIN(3/10*PI)
PRINT 1+2*LSIN(PI/10)
PRINT 2*LSIN(PI/10)+1
PRINT 2*LCOS(2*PI/5)+1
LET S=1
FOR I=1 TO 2000
LET S=1+1/S
NEXT I
PRINT S
LET S=1
FOR I=1 TO 2000
LET S=1+SQR(S)
NEXT I
PRINT SQR(S)
LET S=13/8
LET A=1
FOR N=0 TO 2000
IF N=0 THEN
LET A=-A/2/64
ELSE
LET A=-A*(2*N+1)*2*N/(N+2)/N/16
END IF
LET S=S+A
IF ABS(A)<EPS(0) THEN EXIT FOR
NEXT N
PRINT S
!'SQR(5)=6460/2889*(1-1/8346321)^(-.5)
!'(1-X)^(-1/2)=1+1/2*X+(1*3)/(2*4)*X^2+(1*3*5)/(2*4*6)*X^3+...
LET S=1
LET A=1
LET X=8346321
FOR I=1 TO 1000
LET A=A*(2*I-1)/(2*I)/X
LET S=S+A
IF ABS(A)<EPS(0) THEN EXIT FOR
NEXT I
PRINT (1+6460/2889*S)/2
END
EXTERNAL FUNCTION LCOS(X)
OPTION ARITHMETIC DECIMAL_HIGH
LET S=0
LET A=1
FOR I=1 TO 2000
LET S=S+A
LET A=-X*X*A/(2*I-1)/(2*I)
IF ABS(A)<EPS(0) THEN EXIT FOR
NEXT I
LET LCOS=S
END FUNCTION
EXTERNAL FUNCTION LSIN(X)
OPTION ARITHMETIC DECIMAL_HIGH
LET S=0
LET A=X
FOR I=1 TO 2000
LET S=S+A
LET A=-X*X*A/(2*I+1)/(2*I)
IF ABS(A)<EPS(0) THEN EXIT FOR
NEXT I
LET LSIN=S
END FUNCTION
----------------------------------------------------------------------------
OPTION ARITHMETIC DECIMAL_HIGH
PUBLIC NUMERIC N
INPUT N
LET XX=3
DO
LET X=XX
LET XX=X-F(X)/DF(X)
LOOP UNTIL ABS(X-XX)<EPS(0)
PRINT XX
PRINT (N+SQR(N*N+4))/2
END
EXTERNAL FUNCTION F(X)
LET F=X*X-N*X-1
END FUNCTION
EXTERNAL FUNCTION DF(X)
LET DF=2*X-N
END FUNCTION
----------------------------------------------------------------------------
OPTION ARITHMETIC DECIMAL_HIGH
FOR I=1 TO 400
LET A$=A$ & STR$(I)
IF LEN(A$)>=1000 THEN EXIT FOR
NEXT I
LET X=VAL("." & A$)
PRINT X !'チャンパーノウン定数
FOR I=1 TO 100
IF X=B THEN STOP
LET X=1/(X-B)
LET B=INT(X)
PRINT B;","; !'連分数展開
NEXT I
END
----------------------------------------------------------------------------
OPTION ARITHMETIC DECIMAL_HIGH
LET A=1.3063778838630806904686144926026057129167845851567136443680537599664340537668 !'ミルズの定数
FOR N=1 TO 6
PRINT INT(A^(3^N)+.5) !'素数
NEXT N
END
----------------------------------------------------------------------------
OPTION ARITHMETIC DECIMAL_HIGH
LET Ω=LAMBERTW(1)
PRINT "OMEGA=";Ω
!'PRINT "OMEGA=";LEXP(-Ω) !' Ωexp(Ω)=1 Ω=exp(-Ω)
END
EXTERNAL FUNCTION LAMBERTW(Z) !'ランベルトのW関数
OPTION ARITHMETIC DECIMAL_HIGH
LET W0=0
DO
LET W=W0
LET W0=W-(W*LEXP(W)-Z)/(LEXP(W)*(W+1)-(W+2)*(W*LEXP(W)-Z)/(2*W+2))
LOOP UNTIL ABS(W-W0)<EPS(0)
LET LAMBERTW=W0
END FUNCTION
EXTERNAL FUNCTION LEXP(X)
OPTION ARITHMETIC DECIMAL_HIGH
FUNCTION S(Y,N)
LET T=Y*X/N
IF ABS(T)<=EPS(0) THEN
LET S=Y+T
ELSE
LET S=Y+S(T,N+1)
END IF
END FUNCTION
LET LEXP=S(1,1)
END FUNCTION
----------------------------------------------------------------------------
OPTION ARITHMETIC DECIMAL_HIGH
LET A=1
FOR K=0 TO 1000
IF K>0 THEN
LET A=A*K*K*K*K*K*K*K*K*K*K/(2*K)/(2*K)/(2*K)/(2*K)/(2*K)/(2*K+1)/(2*K+1)/(2*K+1)/(2*K+1)/(2*K+1)
END IF
LET S=S+(-1)^K*A*(205*K^2+250*K+77)
IF S=SS THEN EXIT FOR
LET SS=S
NEXT K
PRINT S/64 !'ゼータ関数ζ(3)
END
----------------------------------------------------------------------------
OPTION ARITHMETIC DECIMAL_HIGH
LET A=1
FOR K=1 TO 2000
LET A=A*256*(2*K)*(2*K)*(2*K)*(2*K-1)*(2*K-1)*(2*K-1)*K*K/(4*K-3)/(4*K-3)/(4*K-2)/(4*K-2)/(4*K-1)/(4*K-1)/(4*K)/(4*K)
LET S=S+(-1)^(K-1)*A*(40*K^2-24*K+3)/(2*K-1)/K/K/K
IF S=SS THEN EXIT FOR
LET SS=S
NEXT K
PRINT S/64
END
----------------------------------------------------------------------------
OPTION ARITHMETIC DECIMAL_HIGH
PRINT 4*ARCSINLEMN(1/2)+2*ARCSINLEMN(7/23)
PRINT 4*ARCSINLEMN(2/3)-2*ARCSINLEMN(7/137)
END
EXTERNAL FUNCTION ARCSINLEMN(X) !'INTEGRAL(1/SQR(1-t^4))dt
OPTION ARITHMETIC DECIMAL_HIGH
LET A=X
LET S=X
DO
LET I=I+1
LET A=A*(2*I-1)/2/I*X^4
LET S=S+A/(4*I+1)
LOOP UNTIL ABS(A)<EPS(0)
LET ARCSINLEMN=S
END FUNCTION
|
|