i need help with the matlab assigment i have done all the part but i just need to store them in vector and display the user output number and all its divisors in a meaningful
2 views (last 30 days)
Show older comments
- Ask the user to input an integer number between 50 and 100.
- Check the user input. If the input is not an integer within the specified range,
display an error message and ask the user for another input. Iterate this process
until satisfactory input is obtained.
- Find all the divisors of the given number and store them in a vector.
- Display the user input number and all its divisors in a meaningful way.
Test your program with three user inputs: 49, 56, and 57.
Answers (1)
Steven Lord
on 27 Sep 2022
sum = 0;
x = input ( 'please input an integer number between 50 and 100;');
while (rem(x,1)~=0) || (x<50)|| (x>100)
x = input('your input is not an integer between 50 and 100 please try again:');
end
So this satisfies the first two bullet points in your assignment pretty well. [You might want to check that the user entered only one number and not something like [75 91] at the prompt.] Next tackle the third bullet point:
- Find all the divisors of the given number and store them in a vector.
If I gave you a number, say 60, what process would you follow with pencil and paper to find all the divisors? Start writing the steps you'd follow as comments. Once you have your workflow documented, start implementing each step. If you're not sure how to perform one or more of the steps in MATLAB, search the documentation to see if there's a function that will perform that step for you and/or break the step down into smaller sub-steps that you know how to implement.
4 Comments
See Also
Categories
Find more on Number Theory 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!