answersLogoWhite

0


Best Answer

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

6y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the algorithm and flowchart for finding the prime numbers between 1 and 20?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the flowchart for finding the prime numbers?

yes


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.


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


Write a algorithm and flowchart to find largest among N numbers?

Max = 0For K = 1 to NIf Number(K) > Max then Max = Number(K)Next KPrint Max


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