def test_sum_cons_equivalence(self): """Test equivalence of sum_consecutive_nums, to subtracting two partial sums.""" k = 7 n = 40 result = seriesutils.sum_consecutive_nums(k,n) partial_difference = seriesutils.partial_sum(n) - seriesutils.partial_sum(k-1) self.assertEqual(partial_difference, result)
def main (): abundantLimit = 28123 primes = [] abundants = [12] splittableSum = 0 for n in xrange(13, abundantLimit+1): if is_abundant(n, primes): abundants.append(n) if is_abundant_splittable(n, primes, abundants): splittableSum += n totalSum = partial_sum(abundantLimit) print "splittableSum: %d, total sum: %d" % (splittableSum, totalSum) return totalSum - splittableSum
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) ) ) ) )