CSC300: 3D Pyramid [10/19] Previous pageContentsNext page

01
02
03
04
05
06
07
    for (long i = 1; i <= N; i = i+1) {
      for (long j = 1; j <= i; j = j+1) {
        for (long k = 1; k <= j; k = k+1) {
          result = result+1;          
        }
      }
    }

Output









Elapsed count f(            8):              120:      6.000 [     0.000 :        NaN]
Elapsed count f(           16):              816:      6.800 [     0.000 :        NaN]
Elapsed count f(           32):            5,984:      7.333 [     0.000 :        NaN]
Elapsed count f(           64):           45,760:      7.647 [     0.001 :   Infinity]
Elapsed count f(          128):          357,760:      7.818 [     0.001 :      1.000]
Elapsed count f(          256):        2,829,056:      7.908 [     0.005 :      5.000]
Elapsed count f(          512):       22,500,864:      7.953 [     0.011 :      2.200]
Elapsed count f(        1,024):      179,481,600:      7.977 [     0.091 :      8.273]
Elapsed count f(        2,048):    1,433,753,600:      7.988 [     0.683 :      7.505]
Elapsed count f(        4,096):   11,461,636,096:      7.994 [     5.322 :      7.792]
Elapsed count f(        8,192):   91,659,526,144:      7.997 [    42.736 :      8.030]
Elapsed count f(       16,384) aborted execution after a minute or so
Elapsed count f(       32,768) aborted execution after a minute or so
Elapsed count f(       65,536) aborted execution after a minute or so
Elapsed count f(      131,072) aborted execution after a minute or so
Elapsed count f(      262,144) aborted execution after a minute or so
Elapsed count f(      524,288) aborted execution after a minute or so
Elapsed count f(    1,048,576) aborted execution after a minute or so
Elapsed count f(    2,097,152) aborted execution after a minute or so
Elapsed count f(    4,194,304) aborted execution after a minute or so
Elapsed count f(    8,388,608) aborted execution after a minute or so
Elapsed count f(   16,777,216) aborted execution after a minute or so
Elapsed count f(   33,554,432) aborted execution after a minute or so
Elapsed count f(   67,108,864) aborted execution after a minute or so
Elapsed count f(  134,217,728) aborted execution after a minute or so
Elapsed count f(  268,435,456) aborted execution after a minute or so
Elapsed count f(  536,870,912) aborted execution after a minute or so
Elapsed count f(1,073,741,824) aborted execution after a minute or so
Elapsed count f(2,147,483,648) aborted execution after a minute or so

This is cubic: ~ 1/6 * N^3

It's a tetrahedron (image from Dune Project):

tetrahedron

Previous pageContentsNext page