Changes between Version 2 and Version 3 of libpipi/sandbox
- Timestamp:
- 10/22/2008 03:57:47 PM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
libpipi/sandbox
v2 v3 26 26 $x = k - y$ 27 27 }}} 28 29 The following C code works OK for values up to 10,000 (higher values may cause overflows), which potentially allows for procedural terapixel images. 30 31 {{{ 32 #!c 33 for(int y = 0; y < 10000; y++) 34 for(int x = 0; x < 10000; x++) 35 { 36 int n = (x + y) * (x + y + 1) / 2 + y; 37 int k = (sqrt((double)(n * 8 + 1)) - 1) / 2; 38 int y2 = n - k * (k + 1) / 2; 39 int x2 = k - y2; 40 if(x != x2 || y != y2) 41 printf("ERROR! %i %i -> %i -> %i %i\n", x, y, n, x2, y2); 42 } 43 }}}