limit = 10 0.upto(limit) do |x| 0.upto(limit) do |y| 0.upto(limit) do |z| w = x*x + y*y +z*z - x*y*z printf( "( %2d , %2d , %2d ) : %3d\n" , x , y , z , w ) end end end