**Understanding Computer Programming**
Osher Lifelong Learning Institute

University of Illinois, Urbana-Champaign
Scott Badman, Instructor

**Topic: Prime program
**** implemented in QuickBasic with protective IF-ELSE-ENDIF**

**February 11,
2016**

`
PRINT "Please enter a number to see if it is a prime:"`

INPUT number

prime$ = "True"

**IF number < 0 OR number > 1000000 THEN**

**PRINT "Number out of range."**

**ELSE**

IF number = 0 OR number = 1 THEN

**prime$ = "False"**

**ELSE**

divisor = 2

WHILE divisor < number

intermediate = number

WHILE intermediate >= divisor

intermediate = intermediate - divisor

WEND

remainder = intermediate

IF remainder = 0 THEN

prime$ = "False"

END IF

divisor = divisor + 1

WEND

**END IF**

IF print$ = "True" THEN

PRINT number; " is a prime."

ELSE

PRINT number; " is not a prime."

END IF

**END IF**

`
``
`

`
`**Understanding Computer Programming**
Osher Lifelong Learning Institute

University of Illinois, Urbana-Champaign
Scott Badman, Instructor