Advertisement
lucast0rres

Lista 3 - 1.28

Apr 28th, 2016
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. #This algorithm was crated by Lucas Pereira Torres de Araujo
  2. #Lista 3 - FUP's Class - 2016.1
  3. #Item 1.28
  4.  
  5. print ">>> H = 1 + 1/2 + 1/3 + 1/4+ ... + 1/N <<<\n"
  6. n = input("Digite o valor de N: ")
  7. x = 0
  8. i = 0
  9.  
  10. if n == 0:
  11.         print ">>> Nao eh possivel realizar esse calculo."
  12.        
  13. while n >= 1:
  14.         i += float(1)
  15.         x += float(1/i)
  16.         n -= 1
  17.  
  18. print "H =", x
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement