(A) Three distinct positive integers belong to a
harmonic sequence. One of these integers equals the product of the other two, and their sum is 1983. Determine the three integers.
(B) Determine three distinct positive integers, belonging to a harmonic sequence, whose product is 3600.
list
10 Lim=sqrt(1983)
20 A=1
22 while A<Lim
24 B=A+1
25 while B*A+A+B<=1983
38 C1=(1//B-(1//A-1//B))
39 if C1>0 then
40 :C=1//(1//B-(1//A-1//B))
50 :if C=int(C) then
60 :if C=A*B then
70 :if A+B+C=1983 then print
80 B=B+1
90 wend
95 A=A+1
100 wend
110 Lim=3600^(1/3)
120 A=1
122 while A<Lim
124 B=A+1
125 while B*A<=Lim*Lim
138 C1=(1//B-(1//A-1//B))
139 if C1>0 then
140 :C=1//(1//B-(1//A-1//B))
150 :if C=int(C) then
160 :if A*B*C=3600 then
170 :print A,B,C
180 B=B+1
190 wend
195 A=A+1
200 wend
OK
The double slashes keep the fractions as rational numbers, rather than dividing to a decimal (actually binary) approximation, in this language, UBASIC.
The solutions are:
run
31 61 1891
12 15 20
OK
|
Posted by Charlie
on 2006-10-27 11:42:05 |