Solving Pascal's Triangle with a Formula! (Thanks to Cang Hai)

The image above is from Wikipedia and is used to explain Pascal’s triangle. Today’s topic is the so-called Pascal’s triangle. Some people also call it Yang Hui’s triangle or Jia Xian’s triangle. The first row’s first entry is “1”. Each number below equals the sum of the number to its upper left and the number to its upper right. If there is no number to the upper left or upper right, it counts as 0. For example, the second row has two numbers, “1, 1”. The third row is “1, 2, 1”. And this triangle can extend infinitely. ...

July 24, 2011 · 2 min

How to Convert a Decimal Number to Binary?

I expect someone will say this article is too simple again once I finish writing it... Without further ado: this week, our teacher gave our class a problem, which is how to convert a decimal number to binary. If you do it with math, it isn't hard. Just use short division and take the remainders. ...

April 16, 2011 · 2 min

[C++] How to Do Exponentiation and Square Roots (sqrt, pow)

In some programming languages, you can do exponentiation directly with the ^ operator. But while working on a problem, I found out that in C++, you have to use the pow function to do exponentiation. This article introduces two functions: pow, which does exponentiation for you, and sqrt, which takes square roots. ...

March 18, 2011 · 1 min