Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- '''Work in Progress: A library I created to solve euler problems and other complex math.'''
- def isPalindrome(n): # Tells whether or not a number is palindrome.
- return n == n[::-1]
- def fib(n): # Creates a list containing the Fibonacci series.
- result = []
- a, b = 0, 1
- while a < n:
- result.append(a)
- a, b = b, a+b
- return result
- def pfact(n): # Prime Factorization of n.
- result = []
- while n >= 2:
- until = int(math.sqrt(n))+1
- for i in range(2,until):
- if not n%i:
- result.append(i)
- break
- else:
- result.append(n)
- return result
- n //= i
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement