Advertisement
FelipeNeto2

Número triângular

Jul 25th, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.22 KB | None | 0 0
  1. n = int(input("Digite o número: "))
  2.  
  3. flag=False
  4. cont = 1
  5.  
  6. while cont<n:
  7.   num = (cont-1)*cont*(cont+1)
  8.  
  9.   if(num==n):
  10.     flag = True
  11.  
  12.   cont+=1
  13.  
  14.  
  15. if flag==True:
  16.   print("Acertou!")
  17. else:
  18.   print("Errou!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement