예제 #1
0
 def test_sum_sequence_trivial(self):
     self.assertEqual(0, bigops.list_to_int(bigops.sum_sequence([])))
     for num in xrange(0, 1000, 13):
         self.assertEqual(num, bigops.list_to_int(\
                                 bigops.sum_sequence(\
                                   [bigops.int_to_list(num)] ) ) )
예제 #2
0
 def test_sum_sequence_triangle(self):
     n = 100 # 100th triangle number
     self.assertEqual(seriesutils.partial_sum(n),
                      bigops.list_to_int(\
                                 bigops.sum_sequence(\
                                    ( bigops.int_to_list(x) for x in xrange(1, n+1) ) ) ) )
예제 #3
0
 def test_mul_simple(self):
     a = 123
     b = 456
     self.assertEqual(a*b, bigops.list_to_int(bigops.mul(bigops.int_to_list(a), \
                                                         bigops.int_to_list(b))))
예제 #4
0
 def test_mul_sequence_factorial(self):
     n = 10
     self.assertEqual(combinatorics.factorial(n), \
                      bigops.list_to_int(\
                         bigops.mul_sequence(( bigops.int_to_list(d) for d in xrange(1, n+1) )) ) )
예제 #5
0
 def test_mul_trivial(self):
     self.assertEqual(1, bigops.list_to_int(bigops.mul([1], [1])))
     for num in xrange(0, 1000, 13):
         self.assertEqual(num, bigops.list_to_int(\
                                 bigops.mul(\
                                   bigops.int_to_list(num), [1] ) ) )
예제 #6
0
 def test_conversion_to_list(self):
     for num in xrange(0, 1000, 13):
         self.assertEqual(num, bigops.list_to_int(bigops.int_to_list(num)))
예제 #7
0
def main (n):
    # calculate factorial
    digits = bigops.mul_sequence(( bigops.int_to_list(d) for d in xrange(1, n+1) ))
    return sum(digits)
예제 #8
0
def main (power):
    digits = bigops.mul_sequence( (bigops.int_to_list(2) for d in xrange(1, power+1)) )
    return sum(digits)
예제 #9
0
def gen_sequence(lastNum):
    for i in xrange(1, lastNum+1):
        print i
        yield bigops.mul_sequence(( bigops.int_to_list(i)[-10:] for d in xrange(1, i+1) ))