123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- __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:
- break
- return x
- def ip():
- """
- get public ip
- """
- return __salt__["http.query"]("https://checkip.amazonaws.com/", method="GET")
|