CLEAR
n10=ASC('D')
c02=''
DO WHILE n10 > 0
n = MOD(n10, 2)
n10 = INT(n10 / 2)
c02=STR(n, 1) + c02
ENDDO
MESSAGEBOX(c02)
clear
a=3
b=a
?"孪生素数对:"
for i=3 to 100 step 2
x=0
for j=2 to i-1
if i/j=int(i/j)
x=1
endif
endfor
if x=0
a=i
if a-b=2
?b,a
endif
b=a
endif
endfor
clear
input "请输入一个正整数=" to m
store m to n,n1
x=2
s=1
y=""
do while s<n1
if mod(n,x)=0
n=n/x
s=s*x
y=y+transform(x)+"*"
else
x=x+1
endif
enddo
messagebox(transform(s)+"="+left(y,len(y)-1))
CLEAR
n=5
RS=121
NOTE S型算法
?"S型算法"
lcstr=""
FOR I=1 TO RS
lni=IIF(MOD(I,2*n)>n,n-MOD(I,n)+1,(IIF(MOD(I,2*n)=0,1,MOD(I,2*n))))
lcstr=lcstr+str(lni,2)
ENDFOR
?lcstr
NOTE 错位算法
?"错位算法"
lcstr=""
FOR I=1 TO RS
lni=MOD(INT((i-1)/n)+MOD(i-1,n),n)+1
lcstr=lcstr+str(lni,2...
clear
for i=1 to 100
k=0
cstr=""
for j=1 to i-1
if i % j=0
k=k+j
cstr = cstr+alltrim(str(j))+","
endif
endfor
if k=i
?str(i) +" 完数 :" +left(cstr,len(cstr)-1)
endif
endfor
clear
input "输入行数:" to n
dime a(n,n)
for i=1 to n
?space((n-i)/2*5)
for j=1 to i
if j=1 or i=j
a(i,j)=1
else
a(i,j)=a(i-1,j-1)+a(i-1,j)
endif
??str(a(i,j),5)
endfor
?
endfor
clear
local aa[5,4]
aa[1,1]=1
aa[1,2]=2
aa[1,3]=12
aa[1,4]=123
aa[2,1]=3
aa[2,2]=4
aa[2,3]=34
aa[2,4]=345
aa[3,1]=5
aa[3,2]=6
aa[3,3]=56
aa[3,4]=567
aa[4,1]=7
aa[4,2]=8
aa[4,3]=78
aa[4,4]=789
aa[5,1]=9
aa[5,2]=10
aa[5,3]=910
aa[5,4]=901
*---------------------------...
1-33共33个数字,生成由小到大的
1,2,3,4,5,6
1,2,3,4,5,7
..........
27,29,30,31,32,33
28,29,30,31,32,33
6位数字不相同的新组合
CLEAR
T1=SECONDS()
CREATE CURSOR TEST (A1 N(2),A2 N(2),A3 N(2),A4 N(2),A5 N(2),A6 N(2))
FOR I1=1 TO 33
FOR I2=I1+1 TO 33
...
*问题:ABCDE分别代表5个不相同的数字(每个字母代表1位数字),并且A与E不等于0,求出算式 ABCDE*A=EEEEEE 中各字母所代表的数字<P23>
CLEAR
N1=0
N2=0
FOR I1=1 TO 9
FOR I2=0 TO 9
FOR I3=0 TO 9
FOR I4=0 TO 9
FOR I5=1 TO 9
N1=I1*10000+I2*1000+I3*100+I4*10+I5
...
CLEAR
FOR I=1 TO 26
STORE "" TO A,B
?I,SPACE(26-I)
FOR J=1 TO I
A=A+CHR(J+64)
IF J=1
B=""
ELSE
B=CHR(J+63)+B
ENDIF
ENDFOR
?? A+B
ENDFOR
数字金字塔代码
clear
for i=...
来源:http://www.mzvfp.com/read.php?tid=55600&page=3
作者:陈家驹
?gcd(15,21)
?gcd(125,25)
Function GCD(X, Y)
If X < 0
X = -x && 欧拉算法
Endif
If Y < 0
Y = -Y && 返回 X 和 Y 的 GCD
Endif
If X = 0 Or Y = 0
? "GCD...
第一项:(1/3)-(1/3)*(2/5)
第二项:(1/3)*(2/5)*(3/7)-(1/3)*(2/5)*(3/7)*(4/9)
第三项:(1/3)*(2/5)*(3/7)*(4/9)*(5/11)-(1/3)*(2/5)*(3/7)*(4/9)*(5/11)*(6/13)
第四项:(1/3)*(2/5)*(3/7)*(4/9)*(5/11)*(6/13)*(7/15)-(1/3)*(2/5)*(3/7)*(4/9)*(5/11)*(6/13)*(7/15)*(8/17)
上面数列的特征:分子等差为1,分母等差为2,分母为2倍的分子加1,“-“前、后相邻两项之间,最后...
CLEAR
DO WHILE .T.
INPUT "请输入11-1000000之间的任意数:" TO N
IF N>10^6 OR N<11
MESSAGEBOX("数字超出范围,请重新输入!")
LOOP
ELSE
EXIT
ENDIF
ENDDO
S=2+3+5+7
C=4
FOR LNI=11 TO N
X=LNI
Y=0
DO WHILE X!=0
Y=X%10+Y*10
X=INT(X/10)
ENDDO
IF Y=...
clear
x=34567
y=0
do while x!=0
y=x%10+y*10
x=int(x/10)
?y,x
enddo
clear
num=9876543210123456
for lnI=len(transform(num))-1 to 0 step -1
?lnI,floor(num/10^(lnI))
num=mod(num,10^(lnI))
endfor
MessageBox(dx(987600004321))
Function dx
lparameters Num
z1="分角元拾佰仟万拾佰仟亿拾佰仟"
z2="零壹贰叁肆伍陆柒捌玖"
Num=Int(Num*100)
*MessageBox(num)
lcdx=""
For lnI=Len(Alltrim(Str(Num,16)))-1 to 0 step -1
lcdx=lcdx+Substr(z2,int(Num/10^lnI)*2+1,2)
lcdx=lcdx+Substr(z1,lnI*2+1,2)
Num=MOD(Num,10^l...
messagebox(iif(isPrime(2)=.t.,"质数","非质数"))
FUNCTION isPrime(n)
LOCAL i
IF n <= 3
RETURN n > 1
ENDIF
IF (n % 2 == 0) OR (n % 3 == 0)
RETURN .F.
ENDIF
i = 5
DO WHILE i * i <= n
IF (n % i == 0) OR (n % (i + 2) == 0)
RETU...
nDigit=0
for lnI=1 to 10
nDigit=nDigit+log10(lnI)
endfor
?"阶乘位数:",int(nDigit)+1
clear
T1=seconds()
num=1000000
local azs[num]
lncnt=num-1
for lnI=2 to int(sqrt(num))
If azs[lnI]=.F.
for lnJ=lnI*lnI to num step lnI
* If azs[lnJ]!=.f.
azs[lnJ]=.T.
* lncnt=lncnt-1
* endif
endfor
endif
end...