Is it possible to automatically output many possibilities using a loop?
1 view (last 30 days)
Show older comments
Prayash Thapa
on 11 Mar 2021
Edited: John D'Errico
on 11 Mar 2021
I have the number let's say 100, I found its initial factors which are 4 and 50. I would then like to use these factors to divide by the input 100. 100/50= 2, then 50/2 = 25. You can see the pattern where the denominator becomes the numerator and the answer becomes the denominater but, I would like to know a way to do this automatically without the need of manually typing it down. All the possible outputs will then be stored in a cell array and displayed e.g. [50,4,2,25...]. It doesn't have to be ordered.
Is this possible? I have been trying to do this but have not achieved much progress.
0 Comments
Accepted Answer
John D'Errico
on 11 Mar 2021
Edited: John D'Errico
on 11 Mar 2021
What you want to do does not seem to make a lot of sense, nor how you will get those initial factors. But I'm sure you have some plans for this.
N = 100;
F = [4 50];
F = [F,N./F];
F
I have no clue why you think you need a cell array to store them. But no loop is required as you can see,
You might consider what will happen if the number N was 36, for example, and one of the initial factors you found was 6. In that case, we might see that 36/6 == 6, so 6 will appear twice in that list.
0 Comments
More Answers (0)
See Also
Categories
Find more on Matrix Indexing 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!