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

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

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.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay