photo

prasanta sahoo


SOA University

Last seen: 3 Monate vor Aktiv seit 2015

Followers: 0   Following: 0

Nachricht

Student

Statistik

Feeds

Anzeigen nach

Frage


Write a function called one_per_n that returns the smallest positive integer n for which the sum 1 + 1/2 + 1/3 + … + 1/n , is greater than or equal to x where x is the input argument. Limit the maximum number n of terms in the sum to 10,000 .
function out=one_per_n(x) if x>10000 out=-1; %fprintf('-1\n'); else total=0; for n=1:x; total=(total+(1/n)); end if...

mehr als 9 Jahre vor | 5 Antworten | 0

5

Antworten