Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import floor
- def factors(n):
- result = []
- for i in range(2,n+1): # test all integers between 2 and n
- s = 0;
- while n/i == floor(n/float(i)): # see if is n/i an integer.
- n = n/float(i)
- s += 1
- if s > 0:
- for k in range(s):
- result.append(i) # i is a prime factor s times
- if n == 1:
- return result
- def isprime(n):
- n = abs(int(n))
- if n < 2:
- return False
- if n == 2:
- return True
- if not n & 1:
- return False
- for x in range(3, int(n**0.5)+1, 2):
- if n % x == 0:
- return False
- return True
- def calculate_first_primefibonnacci_after():
- a = 1
- b = 1
- c = 0
- # Assuming that the next prime fibonnacci will be less than this number
- while c < 10000000000:
- c = a + b
- d = isprime(c)
- if d:
- if c > 227000:
- return c
- a = b
- b = c
- def calculate_result(divisors):
- total = 0
- for a in divisors: total += a
- return total
- if __name__ == "__main__":
- number = (calculate_first_primefibonnacci_after()) + 1
- divisors = factors(number)
- result = calculate_result(divisors)
- print "The Second Password is", result
Advertisement
Add Comment
Please, Sign In to add comment