can anyone know to write a mathlab function that takes an input integer "n" and computes the following
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Kavindra Mahapaanamudalige
el 10 de Jun. de 2019
Comentada: Steven Lord
el 10 de Jun. de 2019
0 comentarios
Respuestas (1)
Prasanth Sikakollu
el 10 de Jun. de 2019
Using While loop, try the following function:
function result = getFacWhile(n)
result = 1;
while n ~= 1
result = result * n;
n = n - 1;
end
end
Using for loop, try the following function:
function result = getFacWFor(n)
result = 1;
for i = 2:n
result = result * i;
end
end
Hope this helps
1 comentario
Steven Lord
el 10 de Jun. de 2019
Please don't post solutions to homework problems (or problems that sound like they're probably homework problems) unless the person asking the question has shown the effort they've put in place first.
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!