Python Forum
How do I create a user input for three integers in a range or just the stop input
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I create a user input for three integers in a range or just the stop input
#1
Below is the code which shows Prime numbers and Mersenne Prime Numbers. It also spits out the last digit of a long number which could be prime or not. I would like the number range, "stop" to be used for user input. Any help thank you.
code part which I don't understand how to incorporate user input:

for num in range(3,30,2):
import math
# Python program to check if the input number is prime or not
  
  
def isPrime(num):
    for i in range(2, int(math.sqrt(num)+1)):
        if num % i == 0: 
            return False;
    return num>1;
  
print 2
print 3
print 3
print ("______________")
for num in range(3,30,2):
                 if isPrime(num):
                    if all(num%i!=0 for i in range(3,int(math.sqrt(num))+1, 2)):
          
                        print num
                        print  ((2**num-1)*(2**num)/2)/(2**num)*2+1
                        print ((((2**num-1)*(2**num)/2)/(2**num)*2+1+1)%10)-1
                        print ("______________")
Reply


Messages In This Thread
How do I create a user input for three integers in a range or just the stop input - by Pleiades - Nov-22-2018, 05:41 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Keep getting "SyntaxError: incomplete input" but can't see why. Pedroski55 1 130 Yesterday, 07:39 AM
Last Post: Larz60+
  Waiting for input from serial port, then move on KenHorse 3 1,172 Apr-17-2024, 07:21 AM
Last Post: DeaD_EyE
  Help with to check an Input list data with a data read from an external source sacharyya 3 459 Mar-09-2024, 12:33 PM
Last Post: Pedroski55
  difference between forms of input a list to function akbarza 6 1,108 Feb-21-2024, 08:02 PM
Last Post: bterwijn
  pyaudio seems to randomly halt input. elpidiovaldez5 2 421 Jan-22-2024, 09:07 AM
Last Post: elpidiovaldez5
  Receive Input on Same Line? johnywhy 8 777 Jan-16-2024, 03:45 AM
Last Post: johnywhy
  manually input data jpatierno 0 365 Nov-10-2023, 02:32 AM
Last Post: jpatierno
  Using string input for boolean tronic72 3 742 Nov-01-2023, 07:48 AM
Last Post: Gribouillis
  problem in using input command akbarza 4 1,203 Oct-19-2023, 03:27 PM
Last Post: popejose
  problem in entering address of a file in input akbarza 0 677 Oct-18-2023, 08:16 AM
Last Post: akbarza

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020