Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Here is a possible implementation of what you are trying to accomplish using a Sage interact and the prime_range function that slelievre mentions in their answer:

@interact
def FindPrimes(start=1, end=100):
    PrimeList = prime_range(start, end)
    print "There are ", len(PrimeList), " primes between ", start, " and ", end
    print "The next prime after start is ", next_prime(start)
    print "The primes between ", start, " and ", end, " are: "
    for i in range(0,len(PrimeList)):
        print PrimeList[i]

Copy and paste the code into a Sage Cell Server. Press Evaluate. To change the start value the user can go to the input cell, type, for example, 35, and press enter. The Sage Interact then updates the results.