[comp.lang.c] Fast exponents ?

risto@tuura.UUCP (Risto Lankinen) (10/04/90)

Hi!

While figuring out a derivation of a Bresenham's algorithm for drawing
a circle, I got into an interesting property of integers.  Let the code
fragment below speak for itself (please excuse my using '(' for all kinds
of parentheses, as the scandinavian keyboard reserves the corresponding
keys for national alphabets) :

generate()
(
   long n = 0L; /* Number */
   long s = 0L; /* Square */
   long c = 0L; /* Cube */
   long h = 0L; /* Hypercube */
   /* etc. */

   do
   (
      /* etc. */ h+=c; c+=s; s+=n; n++;
      /* etc. */ h+=c; c+=s; s+=n;
      /* etc. */ h+=c; c+=s;
      /* etc. */ h+=c;
      /* etc. */

      /* At this point, h==n^4, c==n^3 and s==n^2 */
      /* To get even higher exponents, the 'etc.' could be taken into use */
   ) while( WHATEVER );
)

Any references in the number theory?

Terveisin: Risto Lankinen
-- 
Risto Lankinen / product specialist ***************************************
Nokia Data Systems, Technology Dept *  2                              2   *
THIS SPACE INTENTIONALLY LEFT BLANK * 2 -1 is PRIME!  Now working on 2 +1 *
replies: risto@yj.data.nokia.fi     ***************************************