Advertisement
LightProgrammer000

Raiz Quadrada (metodo Newton)

Jun 17th, 2023
1,042
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.24 KB | None | 0 0
  1. # Entrada de dados
  2. n = int(input("# Digite N: "))
  3. b = 2
  4.  
  5. while True:
  6.  
  7.     # Calculos
  8.     p = (b + (n / b)) / 2
  9.     p_2 = p * p
  10.     b = p
  11.  
  12.     if ((-1) * (n - p_2)) < 0.001:
  13.         print(f"# Raiz quadrada de {n} = {p:.0f}")
  14.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement