Define an arithmetic sequence - MATLAB Cody - MATLAB Central

Problem 54675. Define an arithmetic sequence

Difficulty:Rate
Given three numbers n, a, and d, define an arithmetic sequence of n terms with a being the initial term of the sequence and d being the common difference of the sequence. If n = 0, then return an empty array since there would be no terms in the sequence.
Examples:
Input [n,a,d] = deal(10,5,2)
Output seq = [5 7 9 11 13 15 17 19 21 23]
Input [n,a,d] = deal(5,2,-3)
Output seq = [2 -1 -4 -7 -10]

Solution Stats

66.67% Correct | 33.33% Incorrect
Last Solution submitted on Jan 09, 2025

Problem Comments

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
1
2
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Problem Recent Solvers26

Suggested Problems

More from this Author1

Community Treasure Hunt

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

Start Hunting!
Go to top of page