Effacer les filtres
Effacer les filtres

How to write a program to find the Factorial for a series of number

1 vue (au cours des 30 derniers jours)
If I wanted to find the Factorial for 1/1! + 2/2! + 3/3! ...+ n/n!. How to take the series as user input and display the output.?

Réponse acceptée

Star Strider
Star Strider le 25 Sep 2021
Take advantage of MATLAB’s vectorisation capability —
N = 10;
ff = (1:N) ./ cumprod(1:N)
ff = 1×25
1.0000 1.0000 0.5000 0.1667 0.0417 0.0083 0.0014 0.0002 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
ffsum = sum(ff)
ffsum = 2.7183
Make appropriate changes to get different results.
.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by