Im a beginner to c# and started on GML so please putup with me if im slow
using System;
class Forever
{
public static void Main ()
{
int digits, k;
string storage;
System.Console.WriteLine("amount of digits you need to calculate?");
storage = Console.ReadLine();
digits = int.Parse(storage);
System.Console.WriteLine(digits);
double pi;
double[] sums = new double[digits];
do
sums[k] = 4*((Math.Pow(-1, k))/(2 * k + 1));
k = k + 1;
while(k<digits);
pi = sums.Sum();
}
}
I dont understand why this code doesnt work? For some reason its having a problem with the k = k+1 operation but i defined k outside of the loop.