Gulshan - MATLAB Cody - MATLAB Central

Gulshan

128418
Rank
1
Badge
10
Score
1 – 2 of 2

Gulshan submitted a Comment to Problem 59050. Determine whether a number is a Higgs prime

Well, here is the Python function to check whether a number is higgs prime or not. def is_higgs_prime(number): # List of the first four Higgs primes higgs_primes = [2, 3, 5, 7] # Check if the number is less than 11 or not a prime number if number <= 7 or not is_prime(number): return False # Check if (number - 1) divides the product of the first four Higgs primes product = 2 * 3 * 5 * 7 return (number - 1) % product == 0 def is_prime(n): if n <= 1: return False elif n <= 3: return True elif n % 2 == 0 or n % 3 == 0: return False i = 5 while i * i <= n: if n % i == 0 or n % (i + 2) == 0: return False i += 6 return True # Example usage: number_to_check = 11 if is_higgs_prime(number_to_check): print(f"{number_to_check} is a Higgs prime.") else: print(f"{number_to_check} is not a Higgs prime.") Thanks

on 3 Oct 2023

1 – 2 of 2
Go to top of page