Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Happiest programmers?

Name: faggot 2011-07-26 15:24

Name: Anonymous 2011-07-28 2:52

>>2

#include <cstdio>
#define T long

struct Z {T R,I;};
Z m(Z l,Z r){return{l.R*r.R+5*l.I*r.I,l.R*r.I+l.I*r.R};}
Z s(Z l,Z r){return{l.R-r.R,l.I-r.I};}
Z x(Z e, T n){Z r={1,0};for(;n;n>>=1){if(n&0x1)r=m(r,e);e=m(e,e);}return r;}
T f(T n){Z p={1,1},_=s(x(p,n),x(s({2,0},p),n));return _.I/(1<<n);}

// The entry point to our program
int main(
    int   argc,   // The number of arguments to command-line binary (unused)
    char* argv[]  // An array of char* arguments to command-line binary (unused)
) {
    // The beginning of our program

    // Execute the following interior code 15 times
    for (int i=0; i<15; i++) {
   
        // Evaluate f at every integral value along the interval [0, 15).
        // "%d" signifies the result will be interpreted as a signed integer.
        // A space is included following the "format string" to provide a
        //   neatly formatted output
        printf("%d ", f(i));
       
    }
    // End of interior code section
   
    // Return a success code to the operating system
    return 0;
   
    // The end of our program
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List