Problem 51813. Sum the elements in rows of the Levine triangle
The Levine triangle starts as follows:
Row 0: 2
Row 1: 1 1
Row 2: 1 2
Row 3: 1 1 2
To construct each row, read the previous from the right. Row 0 tells us to put two 1s in row 1. Row 1 tells us to put one 1 and one 2 in row 2. Row 2 tells us to put two 1s and one 2 in row 3. Et cetera.
Write a function that computes the sum of the elements in the nth row of the Levine triangle and reports the sum as a string. Codes that can handle the optional tests will earn ten (10) Chris R. Appreciation Points.
Solution Stats
Problem Comments
-
4 Comments
Show
1 older comment
ChrisR
on 24 May 2021
My code choked on n = 12 on my laptop. That was the motivation for the three optional tests, as well as for one of the tags.
Tim
on 14 Jun 2021
Disallowing 'if' seems to disallow 'circshift' also, which I assume was not your intent.
ChrisR
on 15 Jun 2021
Correct. I changed the test to look for 'if '.
Solution Comments
Show commentsGroup

Sequences & Series V
- 16 Problems
- 5 Finishers
- Solve a nonlinear difference equation
- Iterate the sum of divisors and totient
- Sum the elements in rows of the Levine triangle
- Find the smallest integer m such that n divides m!
- Identify Ruth-Aaron numbers
- Find numbers in the Popular Computing Z-sequence
- Find the nth nude number
- Determine whether a number is a fibodiv number
- List modest numbers up to n
- List the vile numbers
- List the dopey numbers
- Compute the Sequence of the Day
- Classify product/digit-sum sequences
- Count unique orderings of vertices of a polygon
- Count the ways to draw non-intersecting chords between points on a circle
- Fill a rectangle with 1x1 and 2x2 tiles
Problem Recent Solvers12
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!