Skip to content

Instantly share code, notes, and snippets.

@Tokiyomi
Created October 21, 2022 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tokiyomi/a983b6e1fd2bfed7036b63aa42758cfd to your computer and use it in GitHub Desktop.
Save Tokiyomi/a983b6e1fd2bfed7036b63aa42758cfd to your computer and use it in GitHub Desktop.
powers of two in C#
// Powers of two in C#
static List<long> powers_of_two(int N)
/*
This function generates my proposed tactical N sets of numbers made of powers of 2
and the remaining N-30 numbers will be the last N numbers before 10**9 inclusive.
As N is always 100, this fuction is always performed without problems
*/
{
var A = new List<long>();
for (double i = 0; i < 30; i++) // Add 30 tattical numbers
{
A.Add(Convert.ToInt64(Math.Pow(2, i)));
}
for (int i = 0; i < N-30; i++) // Add N-30 ramaining numbers (they can be whatever)
{
A.Add(Convert.ToInt64((Math.Pow(10, 9)))-i);
}
return A;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment