Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Swift program to display first 100 prime numbers. Display 10 prime numbers per line. Prime number an integer greater than 1 is prime

Write a Swift program to display first 100 prime numbers. Display 10 prime numbers per line. Prime number an integer greater than 1 is prime if the only positive divisor is 1 or itself. For instance, 2, 3, 5 and 7 are prime numbers, but 4, 6, 8 and 9 are not. The program is to display the first 100 prime numbers in 10 lines, each line displays 10 prime numbers. The problem can be solved using loops: a. Set a loop counter to 0 and initial number to be tested to 2 b. Start loop iteration and determine whether the number is prime c. If the number is prime, display the number (on same line or next line) and increment the loop counter by 1 d. Increment the number by 1 e. Repeat steps b-d as long as the loop counter is 100 or less f. The loop terminates when the loop counter is greater than 100

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

More Books

Students also viewed these Databases questions

Question

how does health insurance apps work for members?

Answered: 1 week ago

Question

Distinguish between formal and informal reports.

Answered: 1 week ago

Question

=+5 Does this case provide an example of the future for IHRM?

Answered: 1 week ago

Question

=+4 How did it affect HR?

Answered: 1 week ago