geeksforgeeks
Data Structure
Java
Python
HTML
Interview Preparation
  • Tutorials
  • Courses
  • Tracks
  • DSA
  • Practice Problems
  • C
  • C++
  • Java
  • Python
  • JavaScript
  • Data Science
  • Machine Learning
  • Courses
  • Linux
  • DevOps
Videos
January 08, 2025 |19.9K 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
71.7K Views | 11/01/2025...
Program to Find the Sum of All Digits of a Number
Video Thumbnail
10:37
Video Thumbnail
24.5K Views | 09/01/2025...
Graham Scan Algorithm
Video Thumbnail
04:41
Video Thumbnail
9.9K Views | 08/01/2025...
C++ Program to Find Roots of a Quadratic Equation
Video Thumbnail
08:23
Video Thumbnail
6.2K Views | 03/01/2025...
C++ Program on Multiplication of Two Matrices
Video Thumbnail
08:00
Video Thumbnail
3.8K 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.9K Views | 18/07/2024...
C++ Program to Find GCD
Video Thumbnail
10:49
Video Thumbnail
43.5K Views | 17/07/2024...
C++ Program to Calculate Power of a Number
Video Thumbnail
04:45
Video Thumbnail
58.1K Views | 12/07/2024...
JavaScript Program to Find the Factorial of a Number
Video Thumbnail
06:01
Video Thumbnail
17.5K 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
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Campus Training Program
  • Explore
  • POTD
  • Job-A-Thon
  • Blogs
  • Nation Skill Up
  • Tutorials
  • Programming Languages
  • DSA
  • Web Technology
  • AI, ML & Data Science
  • DevOps
  • CS Core Subjects
  • Interview Preparation
  • Software and Tools
  • Courses
  • IBM Certification
  • DSA and Placements
  • Web Development
  • Programming Languages
  • DevOps & Cloud
  • GATE
  • Trending Technologies
  • Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
  • Preparation Corner
  • Interview Corner
  • Aptitude
  • Puzzles
  • GfG 160
  • System Design
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved