Skip to content

Instantly share code, notes, and snippets.

@maxp
Created July 11, 2013 13:23
Show Gist options
  • Select an option

  • Save maxp/5975405 to your computer and use it in GitHub Desktop.

Select an option

Save maxp/5975405 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <complex.h>
#include <math.h>
#ifndef complex
#define complex _Complex
#endif
int main() {
complex double z;
complex double c;
c = 1+2i;
z = 1.+2.i;
int i = 0, n = 100;
while( cabs(z) > 0.01 || i < n) {
z = z*z + c;
i++;
}
printf( "%d %g %gi", i, creal(z), cimag(z));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment