“kode python untuk mencetak bilangan prima” Kode Jawaban

Program Python untuk menemukan N bilangan prima

num = 10
for i in range(2,num+1):
    for j in range(2,i):
        if(i%j == 0):
            break
    else:
        print(i)
GrepDAD

Program Python untuk mencetak bilangan prima dalam interval

lower = 800
upper = 900
print("Print the number's from ",lower," and ",upper,".")
for num in range(lower,upper + 1):
  if num > 1:
    for i in range(2, num):
      if (num % i) == 0:
        break
    else:
      print(num)    
Exuberant Elk

kode python untuk mencetak bilangan prima

# Thanks to https://www.codegrepper.com/profile/farid
# Just tune his answer into easy to use function

def prime_numbers(start_num, end_num):
    for number in range(start_num , end_num + 1):
        is_prime = True
        for counter in range(2,number):
            value = number % counter
            if value == 0:
                is_prime = False
                break
        if is_prime == True:
            print(number)
mathiasgodwin

bilangan prima python

def is_prime(n):
  for i in range(2,n):
    if (n%i) == 0:
      return False
  return True
Atanas Atanasov

bilangan prima di Python

start_num , end_num = input("enter 2 number sepreted by ,:").split(",")
start_num , end_num = int(start_num) , int(end_num)

for number in range(start_num , end_num+1):
    is_prime = True
    for counter in range(2,number):
        value = number % counter
        if value == 0:
            is_prime = False
            break
    if is_prime == True:
        print(number)
Fawlid

Program Python bilangan prima

#prime number or composit number
number=int(input('print number:'))
a=1
while number>a:
    if number%a ==0:
        a+=1
        print("Its composit number")
        break # here break is exicuted then it means else would not be exicuted.
else:
    print("Its a prime number")#this is out of the for loop suite.
Gr@Y_orphan_ViLL@in##

Jawaban yang mirip dengan “kode python untuk mencetak bilangan prima”

Pertanyaan yang mirip dengan “kode python untuk mencetak bilangan prima”

Lebih banyak jawaban terkait untuk “kode python untuk mencetak bilangan prima” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya