Let P ( n ) be the number of triangles with integer side lengths with perimeter lesser than or equal to n .
So P ( 3 ) = P ( 4 ) = 1 , P ( 5 ) = 2 , P ( 6 ) = 3 , P ( 2 5 ) = 1 3 6
Find the sum of digits of P ( 7 1 0 0 0 0 0 ) .
E.g. The sum of digits of 1 2 is 1 + 2 = 3 .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Let a , b , c be the side lengths of a triangle. Without loss of generality, let a ≤ b ≤ c . Hence, for each tuple of a , b , c to represent a unique triangle, a , b , c must satisfy the following inequalities:
a ≤ b ≤ c → a = b + k 0 , c = b + k 1 a + b < c → a + b = c + 1 + k 2
Where k 0 , k 1 , k 2 are non-negative integers. Rearranging the above yields the substitution below:
c b a = k 0 + 2 k 1 + k 2 + 1 = k 0 + k 1 + k 2 + 1 = k 1 + k 2 + 1
P ( n ) can hence be rewritten as the number of non-negative solutions to the diophantine equation a + b + c = 2 k 0 + 4 k 1 + 3 k 2 + 3 ≤ n . This can be computed recursively via the method shown here . This yields:
\[
P(n)=\begin{cases}
\frac{1}{8}(12k^3 - 6k^2 - (-1)^k + 1) & \text{ if } n-3 \equiv 0 \text{ mod } 6 \\
\frac{1}{2}(3k^3 - k) & \text{ if } n-3 \equiv 1 \text{ mod } 6 \\
\frac{1}{8}(12k^3 + 6k^2 + (-1)^k - 1) & \text{ if } n-3 \equiv 2 \text{ mod } 6 \\
\frac{1}{2}(3k^3 + 3k^2) & \text{ if } n-3 \equiv 3 \text{ mod } 6 \\
\frac{1}{8}(12k^3 + 18k^2 + 8k - (-1)^k + 1) & \text{ if } n-3 \equiv 4\text{ mod } 6 \\
\frac{1}{2}(3(k+1)^3 - 3(k+1)^2) & \text{ if } n-3 \equiv 5 \text{ mod } 6
\end{cases}
\text{ Where } k = \left\lfloor \frac{n-3}{6} \right\rfloor + 1 \]
Of course it is not required to derive all 6 cases for the answer but for the sake of completeness I did. My python code to compute the final answer is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
Hey Nice Solution, There is Some error ( Maybe Typo) in the first 2 equations. 1 . b = a + k0, and 2. a+b > c
Problem Loading...
Note Loading...
Set Loading...
I wasn't smart enough to do the math, but I worked pretty hard on this problem, so I want to show my work.