geeksforgeeks
  • Tutorials
  • Courses
Data Structure
Java
Python
HTML
Interview Preparation
  • DSA
  • Practice Problems
  • C
  • C++
  • Java
  • Python
  • JavaScript
  • Data Science
  • Machine Learning
  • Courses
  • Linux
  • DevOps
  • SQL
  • Web Development
  • System Design
  • Aptitude
  • GfG Premium
Videos
January 08, 2025 |12.6K Views

Primality Test (Introduction and School Method)

CPP, prime numbers
 Save  Share  1 Like
Description
Discussion

Given a positive integer, check if the number is prime or not. A prime is a natural number greater than 1 that has no positive divisors other than 1 and itself. Examples of the first few prime numbers are {2, 3, 5, …}
Examples :

Input:  n = 11
Output: true

Input:  n = 15
Output: false

Input:  n = 1
Output: false

Primality Test (Introduction and School Method) : https://www.geeksforgeeks.org/primality-test-set-1-introduction-and-school-method/

Recommendations
Video Thumbnail
10:14
Video Thumbnail
57.0K Views | 11/01/2025...
Program to Find the Sum of All Digits of a Number
Video Thumbnail
10:37
Video Thumbnail
18.1K Views | 09/01/2025...
Graham Scan Algorithm
Video Thumbnail
04:41
Video Thumbnail
9.2K Views | 08/01/2025...
C++ Program to Find Roots of a Quadratic Equation
Video Thumbnail
08:23
Video Thumbnail
5.0K Views | 03/01/2025...
C++ Program on Multiplication of Two Matrices
Video Thumbnail
08:00
Video Thumbnail
3.5K Views | 03/01/2025...
JavaScript Program to Check if Two Strings are Anagrams
Video Thumbnail
03:36
Video Thumbnail
3.0K Views | 16/08/2024...
C++ Program to Return Maximum occurring Character in an Input String
Video Thumbnail
03:12
Video Thumbnail
109.8K Views | 18/07/2024...
C++ Program to Find GCD
Video Thumbnail
10:49
Video Thumbnail
43.4K Views | 17/07/2024...
C++ Program to Calculate Power of a Number
Video Thumbnail
04:45
Video Thumbnail
55.5K Views | 12/07/2024...
JavaScript Program to Find the Factorial of a Number
Video Thumbnail
06:01
Video Thumbnail
17.4K Views | 12/07/2024...
Pangram Checking
GeeksforGeeks
location
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
location
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play StoreGFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy