Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static double CalcPI(int n)
- {
- double pi = 0;
- for (int k = 0; k < n; k++)
- {
- pi += Math.Pow(-1, k) / (2 * k + 1);
- }
- pi *= 4;
- return pi;
- }
- static double sin(double x)
- {
- double result = 0;
- for (int n = 0; n < 10; n++)
- {
- result += Math.Pow(-1, n) * (Math.Pow(x, 2 * n + 1) / Factorial(2 * n + 1));
- }
- return result;
- }
- static long Factorial(int n)
- {
- long result = 1;
- for (int i = 2; i <= n; i++)
- {
- result *= i;
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement