DEV Community

Durga Pokharel
Durga Pokharel

Posted on

1 1

Day 53 Of 100DaysOfCode: More About Algorithm

Greetings everybody. I hope you all are great. Today I started to learn SQL from Data camp. Gain more knowledge about Algorithms. Tried to write some algorithm. Completed some assignment on coursera.

Below is my some algorithm today I tried to write myself.

Python code

python code to find Last Digit of a Large Fibonacci Number.

def calc_fib(n):
    a = 0
    b = 1
    fib = [a,b]
    if n <= 0:
        return n

    else:
        for i in range(1,n):
            f = a + b
            a = b
            b = f
        return b



n = int(input())
print(int(str(calc_fib(n))[-1]))
Enter fullscreen mode Exit fullscreen mode

Output of the code is,

999999
6
Enter fullscreen mode Exit fullscreen mode

Python code to compute gcd of two number

def gcd(a,b):
    m1 = min(a,b)
    m2 = max(a,b)
    CF = []
    for i in range(1,m1+1):
        if m1 % i == 0 and m2 % i == 0:
            CF.append(i)
        return max(CF)

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

When above code run we can get

18 35
1
Enter fullscreen mode Exit fullscreen mode

Day 53 Of #100DaysOfCode and #Python
Hello! everyone. I hope you all guys doing well. Today I return to my 100daysofcode after taking 3 days of brake.
Today's achievement is,
* Learned SQL From Data Camp
* Continue to learned Algorithmic Toolbox
* Tried to write some Algorithms pic.twitter.com/8TX3x5PLkb

— Durga Pokharel (@mathdurga) February 19, 2021

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

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

Okay