Hi Dan,
About 5 weeks ago I thought about this problem in 3D. This is what I came up with.
I am interested in something as close to a cube as possible, so I restricted the range.
Among the more interesting results were: sides 42:42:49--->diagonal 77
simplifying to 6:6:7--->11
The simplest is 1:2:2--->3
uses "oxygen"
dim as string src="
'=============================
' the integer diagonal problem
'=============================
'
'looking for diagonals which have a simple ratio to the lengths of the sides.
' diagonal=sqrt x*x + y*y + z*z
' examples:
'========================
'
' 2D 3 4 --> diagonal 5
' 3D 2 3 6 --> diagonal 7
'========================
'==============================
'3D TABLE: DIAGONAL OF A CUBOID
'==============================
% max 100 'max diagonal
sys b,c,e,i,j,k,l,d[max]
single m
string pr,cr,se
cr=chr(13)+chr(10)
se=chr(9) 'tab
'
'===============================
e=100 'max diagonal
b=2 'min start
m=.4 'min side/diag ratio
'===============================
'
pr="TABLE OF CUBOID DIAGONAL INTEGERS" cr cr
pr+="n" se "x" se "y" se "z" se "diagonal" cr
for i=1 to e
d[i]=i*i
next
do
for i=b to e
for j= i to e
for k=j to e
for l=k to e
if d[i]+d[j]+d[k]=d[l] and i>e*m then
c+=1
if c>40 then exit do 'PROCESS FIRST 40 VALUES ONLY
pr+="" c se i se j se k se l cr
end if
next
next
next
next
exit do
end do
print pr
"
o2_asmo src
if len(o2_error) then
msgbox 0,o2_error
stop
else
o2_exec
end if
Bookmarks