Subject Oriented Programing
Subject Oriented Programing
<p>
Step 1. Start
Step 2. Declare variable of factor = 1.
Step 3. Input number x.
Step 4. Start for loop (initial value 1) less than or equal to the
number given.
Step 5. In the loop multiply factor with i and assign it to and
increment i.
Step 6. Print the value of ans
Step 7. Stop
</p>
3. Write an ALGORITHM to check whether a number entered by the
user is prime or not. In math, prime numbers are whole numbers
greater than 1, that have only two factors – 1 and the number
itself. Ex. Of prime numbers are 2,3,5,7,11,13,17,…
<p>
Step 1: Start
Step 2: Declare variables isPrime = true and x.
Step 3: Input number n.
Step 4: Start for loop(initial value 2) less than or equal num
divided by 2.
Step 5: Inside the loop assign num%i to x,
If x is equal to 0, set is Prime to false, and break
Step 6: Print the value of ans
Step 7: Stop
</p>