Created
November 20, 2013 17:39
-
-
Save d8ta/7567572 to your computer and use it in GitHub Desktop.
Problem ist das er nicht auf 355/113 kommt. Idee?
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
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