

  '=============================
  ' 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,n,x,y,z,d[max]
  single m
  string pr,cr,se

  cr=chr(13)+chr(10)
  se=chr(9) 'tab
  '
  '===============================
  e=100       'max diagonal
  b=5         'min start
  m=.3        'min side/diag ratio
  '===============================
  '
  pr="TABLE OF CUBOID DIAGONAL INTEGERS" cr cr
  pr+="n" se "x" se "y" se "z" se "diagonal" cr

  'calculate squares
  for i=1 to e
    d[i]=i*i
  next

  do
    for x=b to e
      for y=x to e
        for z=y to e
          for l=z to e
            'sum of squares
            i=d[x]+d[y]+d[z]
            if i=d[l]
              if ++c>40 then exit do 'PROCESS FIRST 40 VALUES ONLY
              pr+="" c se x se y se z se l cr
            end if
          next
        next
      next
    next
    exit do
  end do

  print pr
