write an algorithm and draw a flowchart to find prime numbers between 1 to 100
Answers
Answered by
12
Explanation:
hopes it helps..
stay safe stay blessed
Attachments:
Answered by
1
Answer:
Explanation:
- Create a variable called Sum and set its value to
- Using for loop, read a list of numbers from to (in your example).
- Create a count variable and set it to
- Repeat until the first loop is complete.
- The idea behind prime is that num percent itself or num percent num is prime, whereas others aren't.
- Increase the number of people.
- If the count is (for example, ), the remainder ( percent ) is and the remainder ( percent ) is The number must be prime else it will not be prime.
- Increase the total by the prime number you just got.
sum = 0
n1, n2 = map( int, input("Enter numbers with 'SPACE' where 'Start = 2' and End is number of primes required: ").split())
for i in range(n1, n2):
count = 0
for j in range(1, i + 1):
if i % j == 0:
count += 1
if count == 2:
print(f"The Prime Number's are: {i}")
sum += i
print(f'The summation of Prime Numbers from {n1} to {n2} are: {sum}')
Output:
Enter numbers with 'SPACE' where 'Start = 2' and End is the number of primes required: 2 100
The Prime Numbers are:
#SPJ2
Attachments:
Similar questions