anonymous
  • anonymous
can anybody write the algorithm to display all the prime numbers between 1 and 100. Try to formulate a model for picking out the prime numbers from this range and describe the input,processing and the output intended
Computer Science
chestercat
  • chestercat
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

ganeshie8
  • ganeshie8
Using sieve of eratosthenes, you just need to check the divisibility with `2, 3, 5, 7`. Here I provide two different programs in javascript which i hope you may easily convert to an algorithm :
ganeshie8
  • ganeshie8
#Method 1 (sieve of eratosthenes) ``` for (i = 2; i < 100; i++) { if (i != 2 && i % 2 == 0) continue; if (i != 3 && i % 3 == 0) continue; if (i != 5 && i % 5 == 0) continue; if (i != 7 && i % 7 == 0) continue; console.log(i); } ``` https://jsfiddle.net/ej13c8t4/1/
ganeshie8
  • ganeshie8
#Method 2(regular expressions, this is the most inefficient algorithm but also the most coolest) ``` for (i = 2; i < 100; i++) { if ("1".repeat(i).match(/^(11+?)\1+$/)) continue; console.log(i); } ``` https://jsfiddle.net/8bwepcbs/1/

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
http://ideone.com/JKA2ik
anonymous
  • anonymous
ha, that's clever @ganeshie8

Looking for something else?

Not the answer you are looking for? Search for more explanations.