Cody

Problem 45445. Create a vector of the first n natural numbers (★)

Solution 2207866

Submitted on 13 Apr 2020 by Binbin Qi
  • Size: 10
  • This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
n = 10; y_correct = [1 2 3 4 5 6 7 8 9 10]; assert(isequal(first_n_natural_nos(n),y_correct))

ans = 1 2 3 4 5 6 7 8 9 10

2   Pass
n = 4; y_correct = [1 2 3 4]; assert(isequal(first_n_natural_nos(n),y_correct))

ans = 1 2 3 4

Suggested Problems

More from this Author46

Community Treasure Hunt

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

Start Hunting!