Check for Prime

Basic Maths DSA practice problem on Onlearn.

Difficulty: easy.

Topics: How to check whether a given integer N is a prime number, Prime Numbers, Divisors, Mathematical Algorithms, Loops, Conditional Statements, Time Complexity, Space Complexity, Big O Notation, number theory, space complexity, brute force, optimization, time complexity analysis, Prime Numbers, Divisors & Factors.

Given an integer N, determine whether it is a prime number. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Equivalently, a prime number has exactly two distinct positive divisors: 1 and the number itself. Input Specification: The input consists of a single integer N. Output Specification: Return True if N is a prime number, otherwise return False. Examples: Example 1: Example 2: