Prime numbers given range

I have an assignment where I have to use two for loops. I need to ask the user for any two numbers and be able to list all the numbers in between and their factors and state whether or not the number is prime or not. Can anyone help me get started because I do not really know where to begin.
I'd start by understanding the for loop

The first for loop would step through all the values in range specified by the user, and simply print them out as a list.

As for prime numbers, one approach to them is to test whether the number in question is divisible exactly by any whole number (other than 1) smaller than itself. You could use a for loop to do that testing procedure. This topic comes up regularly on this forum, you can find examples (of varying quality) by searching the forum - see the top of this page for the search box. The factors will emerge as a side-effect of testing for primality.

Or equally, it might be said that the number may be found to be prime as a side-effect of finding all the factors. In this case that may be the simpler way of looking at things.

Last edited on
Topic archived. No new replies allowed.