Ad

Write a program to check is the number simple.

It can receive either negative or positive numbers, integer and not integer, simple and not simple.

It should return true if the given number is actually simple (2, 3, 5, 7...)

export const checkIsNumberSimple = (number: number) => {
  // Check if the number is integer
  if (number % 1 != 0) return false;
  
  if (number < 2) return false;
  
  if (number != 2 && number % 2 == 0) return false;
  
  if (number != 3 && number % 3 == 0) return false;

  return true;
};