DEV Community

Durga Pokharel
Durga Pokharel

Posted on

Day 54 Of 100DaysOfCode: More About Algorithm

This is my day 54th of #100DaysOfcode and #python learning. Like yesterday today also continue to learn more about an algorithm. I studied greedy algorithm, implement and analyzed the greedy algorithm, efficient algorithm for grouping children and car fueling in Algorithmic Toolbox
Also learned more properties of SQL including selecting multiple columns from a table, select distinct, use of count, where and, etc From datacamp
Tried to write some efficient algorithm to calculate Fibonacci number, LCM, HCF as a homework assignment of Coursera.

Algorithm to find LCM of two number

def compute_gcd(a,b):
    while(b):
        a, b = b , a % b
    return a
def lcm(a,b):
    lcm = (a*b)//compute_gcd(a,b)
    return lcm

a,b = map(int,input().split())
print(lcm(a,b))
Enter fullscreen mode Exit fullscreen mode

Above code run fast and its outcome is,

714552 374513
170777928
Enter fullscreen mode Exit fullscreen mode

Day 54 Of #100DaysOfCode
* Learned more About SQL From Data Camp
* Learned About Greedy Algorithm
* Tried to write Efficient Algorithm to Calculate LCM #WomenWhoCode #DEVCommunity #CodeNewbie pic.twitter.com/Ngme50mDSH

— Durga Pokharel (@mathdurga) February 20, 2021

Discussion (2)

Collapse
otumianempire profile image
Otu Michael
def compute_gcd(a,b):
    while(b):
        a, b = b , a % b
    return a
Enter fullscreen mode Exit fullscreen mode

You have written different versions of this function...

Collapse
iamdurga profile image
Durga Pokharel Author

thank you for the suggestion.