6

Python Program to Check Prime Number

 1 year ago
source link: https://www.geeksforgeeks.org/videos/python-program-to-check-prime-number/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Python Program to Check Prime Number

Python Program to Check Prime Number
  • 10 Views
  • 10/06/2022

In this video, we will learn how to find prime numbers using python. This video is divided into 5 sections to find prime numbers.

Below is the list of approaches that we will cover in this section:

1. What is prime number 2. Brute fore method to check prime number. 3. Optimal solution for finding prime number. 4. Code in python and its time complexity. 5. Prime number using Recursive method.

A prime number is a natural number greater than 1, which is only divisible by 1 and itself.

First few prime numbers are: 2 3 5 7 11 13 17 19 23. In other words, a number is prime if it is not divisible by any number from 2 to n-1.

In the first approach, we will see the brute force method which has the time complexity of O(N^2), and Space Complexity: O(1). Later we will optimize it and decrease its time complexity with O(N^(3/2)).

Program to print first n prime numbers: https://www.geeksforgeeks.org/program-to-print-first-n-prime-numbers/


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK