Write a function max_product that takes v a vector and n, a positive integer, as inputs and computes the largest product of n consecutive elements of v. It returns the product and the index of the element of v that is the first term of the product.
Show older comments
I can't seem to solve this. Anyone have any idea please?
2 Comments
the cyclist
on 31 Aug 2017
People here are willing to help with homework, but you have to show an effort first. What have you tried? What are your ideas? Where are you stuck?
champions2015
on 1 Sep 2017
Edited: the cyclist
on 1 Sep 2017
Accepted Answer
More Answers (1)
Wu Hanting
on 25 Oct 2018
0 votes
Besides, I think u are supposed to delete the ";" behind the "product = 0" and "ind = -1", or when testing condition of length(v)<n, there won't be any result.
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!