Created
October 5, 2016 11:22
-
-
Save ikr7/898c2197977d2ee75dfecfa63e69a258 to your computer and use it in GitHub Desktop.
マンデルブロ集合(を定義する漸化式)を用いた円周率の近似
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <math.h> | |
#define MAX_ITER 100000000 | |
int N (long double c) { | |
long double z = 0.0; | |
for (int n = 0; n < MAX_ITER; n++) { | |
z = z * z + c; | |
if (z >= 2.0) { | |
return n + 1; | |
} | |
} | |
return 0; | |
} | |
int main () { | |
for (int i = 0; i < 16; i += 2) { | |
printf("%1.10Lf\n", N(0.25 + powl(10, -i)) / powl(10, i / 2)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
参考: https://www.youtube.com/watch?v=d0vY0CKYhPY
出力: