using fprintf to display multiple values
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
carlton letts
il 6 Giu 2020
Risposto: Ameer Hamza
il 7 Giu 2020
i need help with displaying my factorial results
it should be displayed as: exanple The factorial of 3 is 6
heres my code
clear
clc
%the input numbers you want the factorial for%
numlist = input ( ' enter a list of numbers');
numbers = length (numlist);
results =zeros (1, numbers);
for i = 1: numbers;
for ii = i;
facn= prod(1:numlist(i))
fprintf(' The factorial of %.0f is %.0f\n\n',numbers,facn)
end
end
0 Commenti
Risposta accettata
Ameer Hamza
il 7 Giu 2020
Change the line to
fprintf(' The factorial of %.0f is %.0f\n\n',numlist(i),facn)
% ^ use numlist(i) here.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Get Started with MATLAB in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!