-
Notifications
You must be signed in to change notification settings - Fork 0
/
RandomFun.py
28 lines (28 loc) · 999 Bytes
/
RandomFun.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from primelibpy import Prime as p
import random
def gen_Random(name,n,mode):
name="get"+name
x=[]
if name=="getBalancedPrime":
while(len(x)==0):
start = random.randint(10**(n-1),10**n//2)
end = random.randint((10**n//2)+1,(10**n)-1)
x = getattr(p,name)(start,end,mode)
x=list(filter(None, x))
return(random.choice(x))
if name=="getFermatPseudoPrime":
if(mode<2):
print("enter balanced mode greater than one")
return x
while(len(x)==0):
start = random.randint(10**(n-1),10**n//2)
end = random.randint((10**n//2)+1,(10**n)-1)
x = getattr(p,name)(start,end,mode)
x=list(filter(None, x))
return(random.choice(x))
while(len(x)==0):
start = random.randint(10**(n-1),10**n//2)
end = random.randint((10**n//2)+1,(10**n)-1)
x = getattr(p,name)(start,end)
x=list(filter(None, x))
return(random.choice(x))