DEV Community

loading...

Day 8 of 100DaysOfCode: Python Code to Find Out Composite Or Prime Number

iamdurga profile image Durga Pokharel ・1 min read

This is my 8th day of #100daysofcode . Today I learned more about Cascading style sheets which tell the browser how to display the text and other content that we write in HTML. Also, I tired to write some code regarding to some mathematical problems. Below is my code of the day. Which is used to find composite or prime number.

def prime_or_composit(n):
    f = 0
    for i in range(1,int(n/2)+1):
        if n % i == 0:
            f += 1

    if f >= 2:
        print(f"{n} is composit.")
    else:
        print(f"{n} is prime.")
prime_or_composit(5)
Enter fullscreen mode Exit fullscreen mode

Discussion (0)

pic
Editor guide