Construct numbers from antidiagonals of stacks of binary numbers - MATLAB Cody - MATLAB Central

Problem 59242. Construct numbers from antidiagonals of stacks of binary numbers

A sequence is constructed in the following way: Express the numbers 1, 2, 3, 4, 5,… in binary and stack them, right-justified. Then read the numbers in upward sloping diagonals and convert to decimal. The first four binary numbers are 11, 110, 101, 100, and their decimal equivalents are 3, 6, 5, 4.
0 0 0 1
0 0 1 0
0 0 1 1
0 1 0 0
0 1 0 1
0 1 1 0
Write a function to compute the nth term in the sequence.

Solution Stats

62.5% Correct | 37.5% Incorrect
Last Solution submitted on Mar 27, 2024

Problem Comments

Solution Comments

Show comments
R2025a Pre-release highlights
This topic is for discussing highlights to the current R2025a Pre-release.
13
5

Problem Recent Solvers5

Suggested Problems

More from this Author290

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page