Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: UTF-8 -*-
- __author__ = 'Julio Tentor jtentor@gmail.com, Brian Mayo brianmay.dev@gmail.com'
- from math import sqrt
- from functools import reduce
- def isPrime(number):
- if number < 1:
- raise ValueError("Error de argumento en esPrimo")
- if number == 1 or number == 2:
- return True
- if number % 2 == 0:
- return False
- for i in range(3, int(sqrt(number)) + 1, 2):
- if number % i == 0:
- return False
- return True
- def Show(number, dividers):
- print("El numero que buscamos es", number)
- print("Divisores", dividers)
- for divider in dividers:
- print(divider,"+",number,"/",divider,"=",divider + number / divider)
- def test():
- for number in range(10000, 1, -1):
- dividers = [1] + [divider for divider in range(2,number) if number % divider == 0] + [number]
- if reduce(lambda a, b: a and b, list(map(lambda n: isPrime(n), list(map(lambda d: d + number / d, dividers))))):
- Show(number, dividers)
- break
- if __name__ == '__main__': test()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement