Skip to content

Instantly share code, notes, and snippets.

@modamoda
Created December 17, 2012 12:04
Show Gist options
  • Save modamoda/4317827 to your computer and use it in GitHub Desktop.
Save modamoda/4317827 to your computer and use it in GitHub Desktop.
one of possible solutions for https://www.facebook.com/programminglearners/posts/506757269358735 1 232 34543 4567654
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int n = 5;
for (int i = 1; i <= n; i++)
{
int localSum = (2 * i - 1) * (int)Math.Pow(10, i - 1);
for (int k = 0; k < i - 1; k++)
{
localSum += (i + k) * (int)Math.Pow(10, 2 * (i - 1) - k);
localSum += (i + k) * (int)Math.Pow(10, k);
}
Console.WriteLine(localSum);
}
}
}
}
@modamoda
Copy link
Author

Developer's note:
I've wrote this just for fun. BE CAREFUL, this code is NOT EFFICIENT since it contains Math.Pow()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment