Tech Study

Write a Python function that takes a number as a parameter and check the number is prime or not

Introduction

Write a Python function that takes a number as a parameter and check the number is prime or not. I have used python 3.7 compiler for debugging purpose.

def test_prime(num):
    if (num==1):
        return False
    elif (num==2):
        return True;
    else:
        for x in range(2, num):
            if(num % x==0):
                return False
        return True             
print(test_prime(167))

Result

Write a Python function that takes a number as a parameter and check the number is prime or not
Write a Python function that takes a number as a parameter and check the number is prime or not

TaggedWrite a Python function that takes a number as a parameter and check the number is prime or not

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more