Ad
Mathematics
Algorithms
Logic
Numbers
Data Types
Code
Diff
  • mylist = range(1000)
    
    def multiple(arg):
        return sum(x for x in mylist if (x % 3 == 0 or x % 5 == 0))
    
    print(multiple(mylist))
    • mylist = range(1000)
    • def multiple(arg):
    • return sum(list(filter(lambda x: (x % 3 == 0 or x % 5 == 0) and x != 0, arg)))
    • return sum(x for x in mylist if (x % 3 == 0 or x % 5 == 0))
    • print(multiple(mylist))
Mathematics
Algorithms
Logic
Numbers
Fundamentals
Data Types
Code
Diff
  • def compute(n):
    	return sum(x for x in range(n) if (x % 3 == 0 or x % 5 == 0))
    • def compute(n):
    • ans = sum(x for x in range(n) if (x % 3 == 0 or x % 5 == 0))
    • return ans
    • return sum(x for x in range(n) if (x % 3 == 0 or x % 5 == 0))