Question: 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.

**You will need additional loops to determine whether the number is prime.

The output of this program

2 3 5 7 11 13 17 19 23 29

31 37 41 43 47 53 59 61 67 71

73 79 83 89 97 101 103 107 109 113

127 131 137 139 149 151 157 163 167 173

179 181 191 193 197 199 211 223 227 229

233 239 241 251 257 263 269 271 277 281

283 293 307 311 313 317 331 337 347 349

353 359 367 373 379 383 389 397 401 409

419 421 431 433 439 443 449 457 461 463

467 479 487 491 499 503 509 521 523 541

Program ended with exit code: 0

Make sure to apply the followings in your program:

Refer to swift code examples developed in-class and provided in the reading materials

Add comments in your code to document your program

Use descriptive and appropriate variable names/identifiers

Use named constant(s) appropriately

Have proper indentation and line spaces in your source code for readability

Have a HEADER comment block (to include your Name, Date created, Description/Purpose of the program)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!