Contact: aviboots(AT)netvision.net.il
39,959 questions
51,901 answers
573 users
def next_multiple_of_4(num): return num + 4 if num % 4 == 0 else (num + 3) & ~0x03 nums = [21, 16, 0, -9] for num in nums: print(next_multiple_of_4(num)) ''' run: 24 20 4 -8 '''
import math def next_multiple_of_4(num): return math.ceil(num / 4) * 4 nums = [17.902, 21, 16, 0, -9] for num in nums: print(next_multiple_of_4(num)) ''' run: 20 24 16 0 -8 '''