1、已知24有8个正整数因子(即:1,2,3,4,6,12,24),而24正好被其因子的个数8整除。
①求[1,100]之间第10个能被其因子个数整除的正整数。
set talk off
clear
n=0
for i=1 to 100
k=0
for j=1 to i
if mod(i,j)=0
k=k+1
endif
endfor
if mod(i,k)=0
? i &&此处为输出第1至第10个满足条件的数
n=n+1
endif
if n=10
exit
endif
endfor
? "1至100之间第10个能被其因子数目整除的正整数是",i
set talk on
return
②问[100,300]之间有多少个能被其因子数目整除的数。
set talk off
clear
n=0
for i=100 to 300
k=0
for j=1 to i
if mod(i,j)=0
k=k+1
endif
endfor
if mod(i,k)=0
? i
n=n+1
endif
endfor
? "100至300之间有"+str(n)+"个能被其因子数目整除的数"
set talk on
return
2、倒勾股数是满足公式:1/A^2+1/B2=1/C^2的一组正整数(A,B,C),例如,(156,65,60)是倒勾股数,因为:1/156^2+1/65^2=1/60^2。假定A>B>C。
①求A,B,C均小于或等于100的倒勾股数有多少组?
set talk off
clear
n=0
for a=1 to 100
for b=1 to 100
for c=1 to 100
if 1/(a^2)+1/(b^2)=1/(c^2) and a>b and b>c and b>c
? a,b,c
n=n+1
endif
endfor
endfor
endfor
? "a,b,c均小于或等于100的倒勾股数有"+str(n)+"组"
set talk on
return
②求A,B,C之和小于100的倒勾股数有多少组?
set talk off
clear
n=0
for a=1 to 100
for b=1 to 100
for c=1 to 100
if 1/a^2+1/b^2=1/c^2 and a>b and b>c and a+b+c<100
? a,b,c
n=n+1
endif
endfor
endfor
endfor
? "a,b,c之和小于100的倒勾股数有"+str(n)+"组"
set talk on
return
③求满足倒勾股数公式的A,B,C之和的最大值是多少?
set talk off
clear
MAX=100
for a=1 to 100
for b=1 to 100
for c=1 to 100
if 1/a^2+1/b^2=1/c^2 and a>b and b>c
? a,b,c
IF MAX
MAX=A+B+C
ENDIF
ENDIF
endfor
endfor
endfor
? "满足倒勾股数A,B,C之和的最大值是"+str(MAX)
set talk on
return
④求满足倒勾股数公式的各组正整数(A,B,C)中A的值的和是多少?
set talk off
clear
S=0
for a=1 to 100
for b=1 to 100
for c=1 to 100
if 1/a^2+1/b^2=1/c^2 and a>b and b>c
? a,b,c
S=S+A
endif
endfor
endfor
endfor
? "a值的和是",S
set talk on
return
3、已知A
set talk off
clear
c=716699
min=716699
k=int(sqrt(c))
for a=1 to k
b=int(c/a)
if a*b=c and min>a+b
min=a+b &&提示:当A<=B,当A越大,A+B就越小
a=a
? a,b
endif
endfor
?min
set talk on
return
4、求[666,777]范围内素数的个数。(最大的素数是多少?)
set talk off
clear
n=0
max=0
for x=666 to 777
for i=2 to x-1
if mod(x,i)=0
exit
endif
endfor
if i>=x
if max
max=x
n=n+1
endif
endif
endfor
?n,max
set talk on
return
5、求方程X3-2X-5=0在区间[1.5,2.5]上的一个实根。要求:按四舍五入的方