Sn*= sum of integers dividable by 11, write a script program that inputs a large positive integer M, computes the smallest integer n∗such that Sn∗> M, then displays n∗and Sn∗.
1 view (last 30 days)
Show older comments
I am honestly so lost with this question, because 1) the wording is awful and 2) I just don't get while loops. The full question is "Let Sn be the sum of integers that are between 1 and n and are dividable by 11. Write a script program that inputs a large positive integer M, computes the smallest integer n∗such that Sn∗> M, then displays n∗and Sn∗." I have this so far.
M=input('Enter number M:');
I just don't know what else to put
Dyuman Joshi on 22 Sep 2022
Edited: Dyuman Joshi on 22 Sep 2022
You have done quite well despite your limited understanding of the question. Your code requires only a few modifications -
%M=input('Enter number M:');
%random large positive integer
%initiating the sum as 0
We can verify this as well
Torsten on 22 Sep 2022
Edited: Torsten on 22 Sep 2022
rem is treated as an array in your code, not as a function. Thus somewhere you must have created an array called "rem".
E.g. the line
(which makes no sense) would do this.
If you just had copied @Dyuman Joshi 's code, you had no problems.
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!