Created
December 17, 2012 12:04
-
-
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
This file contains hidden or 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 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); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Developer's note:
I've wrote this just for fun. BE CAREFUL, this code is NOT EFFICIENT since it contains Math.Pow()