answersLogoWhite

0

The algorithm is fairly straightforward. For any integer i greater than or equal to zero:

  1. i is non-prime if i is less than 2.
  2. otherwise, i is prime if i is 2.
  3. otherwise, i is non-prime if i is greater than 2 but is divisible by 2.
  4. otherwise, i is non-prime if it has any prime factors less than or equal to its square root.
  5. otherwise, i is prime.

Step 4 is easier to implement by testing all odd divisors from 3 to the square root of i.

User Avatar

Wiki User

7y ago

What else can I help you with?

Related Questions

Write algorithm and draw flowchart to find the sum of even numbers?

jgfujtf


Draw a flowchart to generate odd numbers between 100?

Draw a flowchart to generate odd numbers between 100?


Algorithm and flowchart of odd numbers 1 to 100?

algorithim and flow chart of odd number 1 and 50


Write an algorithm and draw a corresponding flowchart to search a number in the given list of numbers and also display its position?

please give me an algorithm and a corresponding flow chart that displays list of numbers from 1 to 20.


Develop an algorithm to display all prime numbers from 2 to 100 Give both the pseudocode version and the flowchart version Convert your pseudocode into a Java program?

Develop an algorithm to display all prime numbers from 2 to 100. Give both the pseudocode version and the flowchart version. Convert your pseudocode into a Java program.


Give a sample problem with the use of algorithm and flowchart symbols?

design a flowchart that will input three numbers and get their sum. If the sum is greater than 20, then print "sum>20",else print the sum.


Write the algorithm and draw the flowchart to find Sum of N Prime number?

Ah, finding the sum of N prime numbers is a lovely challenge! You can create an algorithm by first defining a function to check if a number is prime, then loop through numbers starting from 2 and add the prime numbers to a running sum until you reach N prime numbers. For the flowchart, you can start with a start/end symbol, then use decision symbols to check if a number is prime, loop symbols to iterate through numbers, and a process symbol to calculate the sum. Remember to add symbols for input and output as well. Happy algorithm painting!


Define flowchart and draw flowchart for GCD of two numbers?

pictorial representation of a program is called a flowchart


How many even numbers can you find between 20 and 40?

Show a modified algorithm flowchart to list even numbers between 20 and 40, 22, 24, 26, 28, 30, 32, 34, 36, 38 and that is 9 numbers


What is the linear time median finding algorithm and how does it work?

The linear time median finding algorithm is a method used to find the median (middle value) of a set of numbers in linear time, meaning it runs in O(n) time complexity. The algorithm works by partitioning the input numbers into groups, finding the median of each group, and then recursively finding the median of the medians until the overall median is found. This approach ensures that the median is found efficiently without having to sort the entire set of numbers.


Write an algorithm or draw a flowchart to display numbers from 100 down to 10?

n=100 loop until n = 9 print n n = n -1 end loop


Write an algorithm and draw a corresponding flowchart to find the greatest number and its position among the 6 given numbers?

Algorithm Step1: Read A, B, C Step2: If A > B is True, then check whether A > C, if yes then A is greatest otherwise C is greatest Step3: If A > B is False, then check whether B > C, if yes then B is greatest otherwise C is greatest Give the Flowchart Answer