![]() Print(num, "is not a prime number") Output 17 is a prime numberĪll the variables are declared in the local scope and their references are seen in the figure above. # If num is divisible by any number between 2 and n / 2, it is not prime Now let’s observe the concept in the implementation below− Example num = 17 If any factor is found in the given range, the number is not prime. Now we check whether the number is exactly divisible by any number in the range of 2 to(num - 1//2). ![]() ![]() Hence, we only iterate if the number is greater than 1. Numbers less than or equal to 1 can not be referred to as prime numbers. In this program below, the number is checked about its prime or non-prime nature. are prime numbers as they do not have any other factors. Problem statement − We are given a number, we need to check whether the given number is a prime number or not.Ī given positive number greater than 1 which has no other factors except 1 and the number itself is referred to as a prime number. In this article, we will learn about the solution to the problem statement given below. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |