Switch act

i have data in excel
67 87.66 44
by using switch activity how to find prime or not and print in column
Number Prime or not

You wouldn’t do it with a Switch. You have to loop from 2 to the square root of the number you’re checking, and calculate if it’s prime.

You can look around online to see different examples of code to check if a number is prime.

Also, decimal numbers cannot be prime numbers. Only integers.

Here is code to check if a number is prime. Note that it does not work for 1 or 2. You’d have to check for those values manually with an if.

Make sure to initialize counter (int32) as 2 and isPrime (boolean) as True. numberToCheck is obviously also int32 and you have to set its value for whatever number you want to test for prime.



FYI, another approach:

As we can easily know prime numbers below a certain number, we can achieve this as the following, if input number is always below the number.

Sample20220812-2.zip (9.4 KB)


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.