Example #1
0
 def add(frac1, frac2):
     n1, n2 = frac1.get_numerator(), frac2.get_numerator()
     d1, d2 = frac1.get_denominator(), frac2.get_denominator()
     l = lcm(d1, d2)
     m1, m2 = l/d1, l/d2
     num = m1*n1 + m2*n2
     rf = fraction(num, l)
     return fraction.reduce_to_lowest_terms(rf)
Example #2
0
 def add(frac1, frac2):
     n1, n2 = frac1.get_numerator(), frac2.get_numerator()
     d1, d2 = frac1.get_denominator(), frac2.get_denominator()
     l = lcm(d1, d2)
     m1, m2 = l / d1, l / d2
     num = m1 * n1 + m2 * n2
     rf = fraction(num, l)
     return fraction.reduce_to_lowest_terms(rf)
Example #3
0
 def __mul__(self, other):
     new_n = lcm(self.n, other.n)
     new_value = (self.value * other.value) % self.n
     return NRing(new_value, new_n)
def range_lcm(m):
    return lcm(*range(2, m + 1))
def f(n):
    #bruteforce
    l=[]
    for y in range(1,n):
        l.append( len([ (x,y)   for x in range(1,y+1) if lcm(x,y)==n]) )
    return sum(l)