Blame view

NumberTheoryandCombinatorics/PrimerNumber/Prime.cpp 416 Bytes
743b077f4   Ronaldo   Update.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
  //
  // Created by ronal on 2/11/2023.
  // Problem Description Link.
  // https://practice.geeksforgeeks.org/problems/prime-number2314/1
  
  class Solution{
  public:
      int isPrime(int N){
          if(N <= 1){
              return 0;
          }else{
              for(int i = 2; i <= sqrt(N); i++){
                  if(N % i == 0){
                      return 0;
                  }
              }
          }
          return 1;
      }
  };