Beauty of Math!
1 x 8 + 1 = 9
12 x 8 + 2 = 98
123 x 8 + 3 = 987
1234 x 8 + 4 = 9876
12345 x 8 + 5 = 98765
123456 x 8 + 6 = 987654
1234567 x 8 + 7 = 9876543
12345678 x 8 + 8 = 98765432
123456789 x 8 + 9 = 987654321
1 x 9 + 2 = 11
12 x 9 + 3 = 111
123 x 9 + 4 = 1111
1234 x 9 + 5 = 11111
12345 x 9 + 6 = 111111
123456 x 9 + 7 = 1111111
1234567 x 9 + 8 = 11111111
12345678 x 9 + 9 = 111111111
123456789 x 9 +10 = 1111111111
9 x 9 + 7 = 88
98 x 9 + 6 = 888
987 x 9 + 5 = 8888
9876 x 9 + 4 = 88888
98765 x 9 + 3 = 888888
987654 x 9 + 2 = 8888888
9876543 x 9 + 1 = 88888888
98765432 x 9 + 0 = 888888888
Brilliant, isn't it?
And look at this symmetry:
1 x 1 = 1
11 x 11 = 121
111 x 111 = 12321
1111 x 1111 = 1234321
11111 x 11111 = 123454321
111111 x 111111 = 12345654321
1111111 x 1111111 = 1234567654321
11111111 x 11111111 = 123456787654321
111111111 x 111111111 = 12345678987654321
This I got by a mail from my friend. Nice one..
By the way, are the results correctly?
So, from next time onwards, if any one asks you to write a program to print the pyramid of numbers, instead of writing using junk loops, use Maths to print it.
Subscribe to:
Post Comments (Atom)
3 comments:
hmm.. I shud disagree with u if u want to print thru code. do u want to give a complex math instead of simple loop with single statement
printf("%d",i);
Look the number of clock cycles in both the cases.
Maths is beautiful, but logic is more beautiful.
I agree that this takes lot of cycles.. 'm not asking you to include this in your project :) but, you ought to appreciate the beauty of maths. It shows how innovative you are if you write a piece of code in different ways.. I guess I can term this as one "out of box" thinking way to write a pyramid program.. may be some of those at present aweful ways may lead to different useful ways later.. :)
ok.. just out of curiosity to learn, can you suggest me where this calculations can be used?
Post a Comment