Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #MBK(a,b) -ieskomas maziausias bendras skaiciu a ir b kartotinis
- a=15015 #ivesk pirma skaiciu nedidesni uz 100 000 cia
- b=1 #ivesk antra skaiciu cia
- primes=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331]
- def factor(x):
- RHS=[]
- for n in primes:
- while x%n==0:
- x/=n
- RHS.append(n)
- if n**2>x: break
- if x>1: RHS.append(x)
- return RHS
- A=factor(a)
- B=factor(b)
- print "Rasime MBK(a,b)"
- print "isskaidome a: a ="," * ".join([str(n) for n in A])
- print "isskaidome b: b ="," * ".join([str(n) for n in B])
- print "vieno skaidinio papildymas kito elementais:"
- C=[[n]*max(A.count(n),B.count(n)) for n in sorted(set(A+B))]
- C=reduce(lambda x,y: x+y, C)
- print " * ".join([str(n) for n in C])
- print "MBK(a,b) = "+" * ".join([str(n) for n in C])+" = "+str(reduce(lambda x,y: x*y, C))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement