renix1

Verificar se é numero perfeito ou n, python 2.x

Dec 20th, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. # coding: utf-8
  2.  
  3. p = 1
  4. while p is 1:
  5.     def verificar_se_perfeito(n):
  6.         '''
  7.             VERIFICA SE UM NÚMERO É PERFEITO OU Ñ
  8.         '''
  9.         teste = 0
  10.         for x in range(1, n):
  11.             if n % x == 0:
  12.                 teste += x
  13.                
  14.         if teste == n:
  15.             return n
  16.         else:
  17.             pass
  18.     a = []
  19.     for x in xrange(0, 10001):
  20.         print 'loading...'
  21.         if verificar_se_perfeito(x):
  22.             a.append(verificar_se_perfeito(x))
  23.     else:
  24.         print('mostrando a:', a)
  25.         p = 0
Advertisement
Add Comment
Please, Sign In to add comment