The code I currently have (slightly modified from earlier) is def divides (n): If anyone can offer some helpful hints or point me in the right direction I would greatly appreciate it!! However, when running my prime function, it always returns True, regardless of whether or not the number is prime When I run the divides function with a number prime number (ie 7) for any one number in the range (2-n) it works perfectly Print (“Is it Prime?”, map (divides, range (2, n)) ) Unfortunately I’m not allowed to use loops or recursion in this assignment, only the ‘divides’ function, mapping, and sum I just started coding for the first time last week so I am very new, but having done some research I found that you could use a ‘for i in range ’. Hi there! I have an assignment to create a code in python that will display a boolean value, depending on whether or not the number (n) entered into the function is prime or not, and I am absolutely stuck.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |