DEV Community

Durga Pokharel
Durga Pokharel

Posted on

2 1

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

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (2)

Collapse
 
otumianempire profile image
Michael Otu
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

thank you for the suggestion.

Sentry image

Make it make sense

Only the context you need to fix your broken code with Sentry.

Start debugging →

👋 Kindness is contagious

Value this insightful article and join the thriving DEV Community. Developers of every skill level are encouraged to contribute and expand our collective knowledge.

A simple “thank you” can uplift someone’s spirits. Leave your appreciation in the comments!

On DEV, exchanging expertise lightens our path and reinforces our bonds. Enjoyed the read? A quick note of thanks to the author means a lot.

Okay