Skip to content

Instantly share code, notes, and snippets.

@d8ta
Created November 20, 2013 17:39
Show Gist options
  • Save d8ta/7567572 to your computer and use it in GitHub Desktop.
Save d8ta/7567572 to your computer and use it in GitHub Desktop.
Problem ist das er nicht auf 355/113 kommt. Idee?
using System;
namespace bsp26
{
class MainClass
{
const double PI = 3.14; // TODO: 3.141592 = 355/113
static double output ;
static double n;
static double m;
public static void Main (string[] args)
{
approximationOfPi ();
}
// function for the approximation of Pi
static void approximationOfPi ()
{
for (m = 0; m <= 10000; m++) {
for (n = 0; n <= 10000; n++) {
output = n / m;
if (output == PI) {
Console.WriteLine ("n = " + n + " m = " + m);
Console.WriteLine (output);
} else {
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment