SHARE

TWEET

# Python LCD

a guest
Feb 23rd, 2019
85
Never

**Not a member of Pastebin yet?**

**, it unlocks many cool features!**

__Sign Up__- # Format your inputs with a : and then a space,
- # it makes them nicer to read :)
- a = int(input("Enter the first denominator: "))
- b = int(input("Enter the second denominator: "))
- # Separate your code that "arranges the world"
- # to avoid repeating your "main logic"
- if a > b:
- x = a
- y = b
- else:
- x = b
- y = a
- # This is the "main logic"
- # because we already figured out whether a or b
- # was the biggest, we don't have to think about
- # it again here.
- factor = 1
- while x * factor % y != 0:
- factor += 1
- # Python's "string interpolation", a fancy way
- # for saying, shoving one string into another,
- # makes everything a bit easier to read :)
- lcd = x * factor
- print "The LCD of %d and %d is %d" % (a, b, lcd)

RAW Paste Data

We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.