def russian(a, b): x = a; y = b z = 0 while x > 0; if x % 2 == 1: z = z + y y = y << 1 x = x >> 1 return z print russian(14, 11)
154
import math def time(n): steps = 0 return 3 + 2 * math.ceil(n/5) print time(50) def countdown(x): y = 0 while x > 0: x = x - 5 y = y + 1 print y print countdown(n)
def naive(a, b): x = a y = b z = 0 while x > 0: z = z + y x = x - 1 return z def time(a) return 2*a + 3
def rec_russian(a, b): if a == 0: return 0 if a % 2 == 0: return 2 * rec_russian(n/2, b) return b + 2* rec_russian((a-1)/2,b)