i have here a programm to find the prime numbers from 0-> 1000.
It is working properly, but i tried to work this out on a flowchart .
(to analyse this better). Unfortionately, it seems more difficult then i thought.
I don’t know exactely how to put a ‘for i in range’ , and in the program, the subroutine is used as expression; so i wonder how to do this ??
the python code is here underneath :
prime = True
if number < 2 :
for j in range(2,number):
if number % j == 0:
prime = False
print("Prime numbers between 1 and 999 ")
for i in range (0,1000):
Flowchart of for loop may look something like this, and the flowchart of function is separated from flowchart of the main program, something like this.
i do understand the first (for in range) problem,
but the second (if isPrime(i)), i still don’t understand.
You have a subroutine in an if statement. How to combine …
In flowchart of main program, draw a box with doubles lines to represent the function isPrime. Now treat it as a blackbox, you feed the value of i into isPrime, and see whether it returns the value of True. If true then print i.
The flowchart of the inner working of isPrime can be drawn separately on the side. Of course you can incorporate it into the flowchart of the main program, but the chart will be more complex.
i understand this, but my problem is : isPrime , is a subroutine , as you said, represent in double lines, but isPrime is also the expression of the ‘if’ instruction. (which is normally be written in the square of the diamant ).
Follow the double lines box with a diamond, or simply omit the box with just stating “if isPrime(i)” inside a decision diamond.
thanks, it seems to me more simple to use "if isPrime(i) inside the decision diamond .