Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Revisions

2 of 3
added 70 characters in body
xnor
  • 149.6k
  • 26
  • 287
  • 676

Python, 17 bytes

lambda a,b:a+-a%b

Try it online!

Since this doesn't use division, it works for both Python 2 and 3. Note that we can't cut out the + sign because a-a%b does a-(a%b), whereas we want to do(-a)%b and add that to a

xnor
  • 149.6k
  • 26
  • 287
  • 676

AltStyle によって変換されたページ (->オリジナル) /