Programming Problem #1 — starting off slow

In his challenge I ask that you do the following things:

Create a program that will:

  1. Use loops to complete the tasks below
  2. Print out a list of all the numbers that meet the following criteria, one item per line.
  3. Are either: Prime, or Multiples of 3, or 8, but not both 3 and 8, less than 2500

Concepts used: Variables, loops, arithmatic functions, breaks

You should be able to do this by: Lesson 13 — 16 will help.

My solution: –Will come back and add one eventually

Please note that my solutions are not checked thoroughly, and should only be used for reference. They are often non-optimal solutions that could be improved upon (by you!). I keep these intentionally rough for just that reason.

One comment

  1. Teronendum says:

    My initial solution, looks to give the right answers, but I’ll check against your solution. My solution isn’t particularly efficient, I’m sure there must be a far more efficient method of calculating primes, and perhaps a relationship between the two divisions. (like in the 3^n homework). Methods would make the code far cleaner too. I’ll update after some looking in to a more efficient prime calculating method.
    http://ideone.com/D5Zbn

Leave a Reply

Your email address will not be published. Required fields are marked *

*