Numbers which are the cube roots of the product of their proper divisors: Difference between revisions
Content added Content deleted
(Numbers which are the cube roots of the product of their proper divisors in FreeBASIC) |
(Numbers which are the cube roots of the product of their proper divisors in various BASIC dialents (BASIC256, True BASIC, XBasic and Yabasic)) |
||
Line 65: | Line 65: | ||
50000th: 223735 |
50000th: 223735 |
||
</pre> |
</pre> |
||
=={{header|BASIC}}== |
|||
==={{header|BASIC256}}=== |
|||
{{trans|FreeBASIC}} |
|||
<syntaxhighlight lang="BASIC256">arraybase 1 |
|||
limite = 500000 |
|||
dim pdc(limite) fill 1 |
|||
pdc[1] = 7 |
|||
for i = 2 to pdc[?] |
|||
for j = i + i to pdc[?] step i |
|||
pdc[j] += 1 |
|||
next j |
|||
next i |
|||
n5 = 500 |
|||
cont = 0 |
|||
print "First 50 numbers which are the cube roots" |
|||
print "of the products of their proper divisors:" |
|||
for i = 1 to pdc[?] |
|||
if pdc[i] = 7 then |
|||
cont += 1 |
|||
if cont <= 50 then |
|||
print rjust(string(i),5); |
|||
if cont mod 10 = 0 then print |
|||
else |
|||
if cont = n5 then |
|||
print |
|||
print rjust(string(cont),9); "th: "; i; |
|||
n5 *= 10 |
|||
end if |
|||
end if |
|||
end if |
|||
next i |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre>Same as FreeBASIC entry.</pre> |
|||
==={{header|True BASIC}}=== |
|||
{{trans|FreeBASIC}} |
|||
<syntaxhighlight lang="qbasic">LET limite = 500000 |
|||
DIM pdc(1 to 500000) |
|||
FOR i = 1 to ubound(pdc) |
|||
LET pdc(i) = 1 |
|||
NEXT i |
|||
LET pdc(1) = 7 |
|||
FOR i = 2 to ubound(pdc) |
|||
FOR j = i+i to ubound(pdc) step i |
|||
LET pdc(j) = pdc(j)+1 |
|||
NEXT j |
|||
NEXT i |
|||
LET n5 = 500 |
|||
LET count = 0 |
|||
PRINT "First 50 numbers which are the cube roots" |
|||
PRINT "of the products of their proper divisors:" |
|||
FOR i = 1 to ubound(pdc) |
|||
IF pdc(i) = 7 then |
|||
LET count = count + 1 |
|||
IF count <= 50 THEN |
|||
PRINT using "####": i; |
|||
IF remainder(count, 10) = 0 THEN PRINT |
|||
ELSE |
|||
IF count = n5 THEN |
|||
PRINT |
|||
PRINT USING "#########th:": count; |
|||
PRINT i; |
|||
LET n5 = n5*10 |
|||
END IF |
|||
END IF |
|||
END IF |
|||
NEXT i |
|||
END</syntaxhighlight> |
|||
{{out}} |
|||
<pre>Same as FreeBASIC entry.</pre> |
|||
==={{header|XBasic}}=== |
|||
{{works with|Windows XBasic}} |
|||
<syntaxhighlight lang="xbasic">PROGRAM "progname" |
|||
VERSION "0.0000" |
|||
DECLARE FUNCTION Entry () |
|||
FUNCTION Entry () |
|||
limite = 500000 |
|||
DIM pdc[limite] '(1 TO limite) |
|||
FOR i = 1 TO UBOUND(pdc[]) |
|||
pdc[i] = 1 |
|||
NEXT i |
|||
pdc[1] = 7 |
|||
FOR i = 2 TO UBOUND(pdc[]) |
|||
FOR j = i + i TO UBOUND(pdc[]) STEP i |
|||
INC pdc[j] |
|||
NEXT j |
|||
NEXT i |
|||
n5 = 500 |
|||
cont = 0 |
|||
PRINT "First 50 numbers which are the cube roots" |
|||
PRINT "of the products of their proper divisors:" |
|||
FOR i = 1 TO UBOUND(pdc[]) |
|||
IF pdc[i] = 7 THEN |
|||
INC cont |
|||
IF cont <= 50 THEN |
|||
PRINT RJUST$ (STRING$(i), 4); |
|||
IF cont MOD 10 = 0 THEN PRINT |
|||
ELSE |
|||
IF cont = n5 THEN |
|||
PRINT "\n"; FORMAT$("#########", cont); "th: "; i; |
|||
n5 = n5 * 10 |
|||
END IF |
|||
END IF |
|||
END IF |
|||
NEXT i |
|||
END FUNCTION |
|||
END PROGRAM</syntaxhighlight> |
|||
{{out}} |
|||
<pre>Same as FreeBASIC entry.</pre> |
|||
==={{header|Yabasic}}=== |
|||
{{trans|FreeBASIC}} |
|||
<syntaxhighlight lang="freebasic">limite = 500000 |
|||
dim pdc(limite) |
|||
for i = 1 to arraysize(pdc(), 1) |
|||
pdc(i) = 1 |
|||
next i |
|||
pdc(1) = 7 |
|||
for i = 2 to arraysize(pdc(), 1) |
|||
for j = i + i to arraysize(pdc(), 1) step i |
|||
pdc(j) = pdc(j) + 1 |
|||
next j |
|||
next i |
|||
n5 = 500 |
|||
cont = 0 |
|||
print "First 50 numbers which are the cube roots" |
|||
print "of the products of their proper divisors:" |
|||
for i = 1 to arraysize(pdc(), 1) |
|||
if pdc(i) = 7 then |
|||
cont = cont + 1 |
|||
if cont <= 50 then |
|||
print i using("###"); |
|||
if mod(cont, 10) = 0 print |
|||
else |
|||
if cont = n5 then |
|||
print "\n", cont using("#########"), "th: ", i; |
|||
n5 = n5 * 10 |
|||
end if |
|||
end if |
|||
end if |
|||
next i</syntaxhighlight> |
|||
{{out}} |
|||
<pre>Same as FreeBASIC entry.</pre> |
|||
=={{header|C++}}== |
=={{header|C++}}== |