arithmetic progression - MATLAB Cody - MATLAB Central

Problem 2800. arithmetic progression

Difficulty:Rate

I've written a program to generate the first few terms of arithmetic progressions. I've noticed something odd though, there's always one wrong term. Surely, there couldn't be a bug in my code, could it?

Can you tell me the position of the wrong term, and return the correct sequence?

For example, given

errorsequence = [2 4 7 8 10]; %arithmetic sequence starting at 2 with increment 2

then

errorposition = 3;
truesequence = [2 4 6 8 10]; 

Solution Stats

14.7% Correct | 85.3% Incorrect
Last Solution submitted on Feb 24, 2025

Problem Comments

Solution Comments

Show comments

Group

Cody Challenge Image
Cody Challenge
  • 12 Problems
  • 465 Finishers

Problem Recent Solvers135

Community Treasure Hunt

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

Start Hunting!
Go to top of page