.NET Fiddle

CSharp · Console

/Program.cs

using System;
					
public class Program
{
	public static void Main()
	{
		int i = 4000;
		while (Test(i)) i++;	
		Console.WriteLine(i);
	}
	
	static bool Test(int value)
	{
		return Math.Round(Convert.ToDouble(value / 1024), 0) <= 4000;
	}
}
;