~cpp import unittest import math def summation(num): return num*(num+1)/2 def eq_2(a,b,c): _2a = 2*a _b_4ac = math.sqrt(b*b-4*a*c) hae1 = (-b + _b_4ac) / _2a hae2 = (-b - _b_4ac) / _2a return hae1, hae2 def minint(num): hae1, hae2 = eq_2(1.0, 1.0, (float)(-2*num)) hae = (int)(max(hae1, hae2)) sum = summation(hae) if( sum < num ): return hae+1, summation(hae+1) else: return hae, sum class TestMinInt(unittest.TestCase): def testSummation(self): self.assertEquals(55, summation(10)) self.assertEquals(10, summation(4)) self.assertEquals(5050, summation(100)) self.assertEquals(500500, summation(1000)) if __name__=='__main__': #unittest.main(argv=('','-v')) print minint(3000)