Python Forum
The infinite sequence of prime numbers
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The infinite sequence of prime numbers
#2
I made a function that verify if a number is prime, hope that is can help your code to be more tiny Big Grin

def is_prime(num):
    mult = [i for i in range(1, num+1) if num % i == 0]
    if len(mult) == 2 and 1 in mult and num in mult:
        return True
    return False
https://gist.github.com/lucasbazan/9a3c4...3431c55532
[Image: LEHoEPo.jpg]
Reply


Messages In This Thread
RE: The infinite sequence of prime numbers - by lucasbazan - Feb-11-2022, 05:36 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Quick prime numbers function ozs 2 3,203 May-14-2018, 08:23 AM
Last Post: ozs

Forum Jump:

User Panel Messages

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