Unformatted text preview: e divisor2 < userNumber if userNumber % divisor is equal to 0 write "The number is not prime, it is divisible by :" write divisor exit program set divisor to divisor +1 write "The number is prime." Writing a Program Define the problem Create a plan (algorithm) to solve the problem Translate your algorithm into code Test and make adjustments to your code and algorithm as neede Creating an Algorithm What to keep in mind when creating your algorithm Read in all needed input Proper output What are the normal cases (possibilities) based on the input? Are there any special cases? Algorithm Example Problem: Find the roots (real) of a quadratic equation. Quadratic Equation: ax2 + bx + c The ro...
View Full Document
- Fall '11
- Quadratic equation, Prime number