python - code that check if number is prime number -


this question has answer here:

i have code check if number prime or note

the problem in code :

when run give error :

take code :

a = int (input("your numbre :")) b = range(1,a+1) if a%b == 0:     in b :         if b == or b == 1:             print("the numbre input prim number") else:     print("the nmubre input note prem numbre") 

take @ error :

traceback (most recent call last):   file "c:\users\admin\desktop\chap8ex2.py", line 3, in <module>     if a%b == 0: typeerror: unsupported operand type(s) %: 'int' , 'range' 

the range function creates array of numbers between parameters. example:

>>> range(1, 4) => [1, 2, 3] 

in code you're saying a%b finding remainder between number user inputted , range object. think of range object python list. you're doing 5 % [1, 2, 3] doesn't make sense. check separate thread find out how implement prime number checker in python. python prime number checker


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -