0% found this document useful (0 votes)
27 views

Lecture2013 02 12

The document provides instructions for finding prime numbers through a trial division algorithm and printing the results in a table. It describes looping through potential divisors from 2 to the number being tested, and labeling the number as prime if no divisors are found less than it. It also includes a nested loop to print the results in a table with row and column headings.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Lecture2013 02 12

The document provides instructions for finding prime numbers through a trial division algorithm and printing the results in a table. It describes looping through potential divisors from 2 to the number being tested, and labeling the number as prime if no divisors are found less than it. It also includes a nested loop to print the results in a table with row and column headings.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Draw a black square Bigger than the biggest star (at leats 2 times radius of star) Centered at ( !

Draw a sequence of stars "tars in alternating colors "tars get smaller

before the #$ % &ou can write for x=0:2:8; y=x; for ' stars (hile is nested in the for loop

How to find prime numbers:

)* "tart a* Di+isor $ 2 2* ,epeat a* ,epeat (n!di+isor) b* Di+isor $ di+isor - ) .* /nd a* ,em(n!di+isor)$ b* Di+isor $ n0

)* Di+isor 2% 2* (hile 11rem(n , divisor ~=0)_ Divisor = divisor + 1; .* /nd 2f di+isor $$n Disp(3prime4) /lse disp(3composite4) /nd

)* 5rint one row at a time - 6printf 2*

6or r $ lo:hi 7at row r! get products with column headings 6or c $ lo:hi 6printf(378d4!r9c) 7if &ou do fprintf(3n:4) here then &ou will ha+e a line after each product /nd 6printf(3:n4) 7print after e+er& row /nd

You might also like