We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Project Euler #148: Exploring Pascal's triangle.
Project Euler #148: Exploring Pascal's triangle.
Sort by
recency
|
13 Discussions
|
Please Login in order to post a comment
To beat all test cases I had to convert row and column values to base 7 and count all triangles in Sierpinski triangle in every cell. My algorithm has 0(log7)^3 complexity. I had wrong answers due to special case for row or column = 0. So keep in mind this special case.
I have tried sum of all natural number ie for 8th row no of elements is S(8) for 8 row and 5 col it is S(8) - S( 8 - 5)
similerly there is some pattern in no divisible by 7 since number for row 14 = S(14) - S( 14 - 14) - (S(14/7) * S(6))
I'm getting timed out!
Is anyone getting the same answer as I got? my output: 12 3842 2852 for input: 3 5 3 100 100 100 50; As per the best of my knowledge I have written correct logic for program. So can you tell me whether my second and third output number is wrong or right?why?
-
Got it for N == R. But not getting it right when R < N. Need to work on it. Any clue?
private static long pascal(int N, int R) { long count = 0; long div71 = 0; // divisible by 7 forming big pattern starting after row 49 long div72 = 0; // divisible by 7 forming small pattern starting after row 7 long div7 = 0; // Divisible by 7 long total = 0; int i = 0;