1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- __func_alias__ = {
- "list_": "list",
- }
- def __virtual__():
- return True
- def _genprimes():
- """
- genarator of primes
- """
- prms = {}
- n = 2
- while True:
- if all([n % pr for pr in prms]):
- yield n
- prms[n] = n**2
- else:
- for key, val in [(x,y) for x, y in prms.items() if y == n]:
- prms[key] += key
- n += 1
- def com(num):
- """
- Function that finds components primes of a given number
- """
- comp = []
- for pr in _genprimes():
- while not num % pr:
- comp.append(pr)
- num /= pr
- if num == 1:
- return comp
- def fib(num):
- """
- Gives the nth fibonacci number
- """
- return __salt__["test.fib"](num)
- def list_(num):
- """
- List all prime numbers below given number
- """
- x = []
- for y in _genprimes():
- if y < num:
- x.append(y)
- else:
- return x
- def ip():
- """
- get public ip
- """
- return __salt__["http.query"]("https://checkip.amazonaws.com/", method="GET")
|