1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Law Incorporation [45]
3 years ago
13

how to create a program that prime number include arraylist , and if not print the prime factors of the number.

Computers and Technology
1 answer:
4vir4ik [10]3 years ago
3 0

Answer:

import math

# Python program for presenting all the prime numbers till an agreed numeral

prime=[]

def findprimeinanarray(n):

   print("Prime numbers admid", 1, "and", n, "are:")

   j=0

   flag=0

   for n in range(1, n + 1):

  # all prime numbers are greater than

      if n > 1:

         for i in range(2, n):

          if (n % i) == 0:

              flag=0

              break

          else:

              flag=1

      if flag==1:

          prime.insert(j,n)

          j=j+1

      else:

          continue

   print(prime[:])        

# A Python function for printing all the prime functions and a Python program to print prime factor

prime1=[]

j=0

# A function to print all the prime factors of a given number if it is not prime

def primeFact(num):

while num % 2==0:

    prime1.insert(2,0)

    num = num/2

 

# num should be odd at this breakpoint

# so we need a shift of 2 ( i = i + 2)

for i in range(3,int(math.sqrt(num))+1,2):

 

 # while i divides num , print i ad divide num

 while num % i== 0:

  num = num /i

 if  num >2:

     j=j+1

     prime1.insert(num,j)

 

 

print(prime1[:])

 

# program to test the coderint

n=600

findprimeinanarray(7)  

k = 45

primeFact(k)

Explanation:

import math

# Python program for presenting all the prime numbers till an agreed numeral

prime=[]

def findprimeinanarray(n):

   print("Prime numbers admid", 1, "and", n, "are:")

   j=0

   flag=0

   for n in range(1, n + 1):

  # all prime numbers are greater than

      if n > 1:

         for i in range(2, n):

          if (n % i) == 0:

              flag=0

              break

          else:

              flag=1

      if flag==1:

          prime.insert(j,n)

          j=j+1

      else:

          continue

   print(prime[:])        

# A Python function for printing all the prime functions and a Python program to print prime factor

prime1=[]

j=0

# A function to print all the prime factors of a given number if it is not prime

def primeFact(num):

while num % 2==0:

    prime1.insert(2,0)

    num = num/2

 

# num should be odd at this breakpoint

# so we need a shift of 2 ( i = i + 2)

for i in range(3,int(math.sqrt(num))+1,2):

 

 # while i divides num , print i ad divide num

 while num % i== 0:

  num = num /i

 if  num >2:

     j=j+1

     prime1.insert(num,j)

 

 

You might be interested in
Anyone wanna join my giggl?
Leni [432]

Answer:

whats a giggl

Explanation:

7 0
2 years ago
Read 2 more answers
What command can be used to export an nps backup file named npsconfig.xml that can be used to restore nps configuration on anoth
irakobra [83]

The command is Export-NpsConfiguration    

An admin can export the entire NPS configuration from one NPS for import to another NPS. Standard precautions should be taken when exporting NPS configurations over the network. The command syntax that can be used for exporting the NPS configurations is Export-NpsConfiguration –Path <filename>


3 0
3 years ago
What advantages do teams have for solving problems
monitta

Answer:

Teams are diverse.

Explanation:

Teams have great advantage in problem solving over single person. A single persons's thinking is one dimensional. He sees and analyse things according to his perspective and understanding which limits his ability to solve problems .On the other hand team consist of multiple people with multiple background and perspective. Everyone has its own thinking process and it's own perspective, there fore in teams if one person is missing some perspective someone else might be looking in to that perspective which greatly enhance teams problem solving

4 0
3 years ago
Which of the following is the most effective password?
zzz [600]
I would have to say that the M3(ury would be the MOST effective, because it has more capitals, numbers, and symbols, which would make it harder to hack into.
5 0
3 years ago
Read 2 more answers
Poems are a kind of persuasive document<br>Yes or no?
Dennis_Churaev [7]

Answer:

i believe the answer yes because the author wants the audience sympathetic attention.

4 0
3 years ago
Other questions:
  • You have received several trouble tickets from the employees in the warehouse for the stand-alone computers used to control vari
    14·1 answer
  • Using the _____ model brings sellers and buyers together on the web and collects commissions on transactions between these parti
    5·1 answer
  • How do you screen shot and copy paste the screenshot from chrome book
    11·2 answers
  • What kind of security features does Microsoft Security Analyzer promise?
    5·1 answer
  • Which segment of society introduced the grunge look?
    5·2 answers
  • Which of the following statements holds true for the term "html"? It refers to a system that connects end users to the Internet.
    10·2 answers
  • Define the missing function. licenseNum is created as: (100000 * customID) licenseYear, where customID is a function parameter.
    12·1 answer
  • According to the video, what is used to create computer programs?
    12·2 answers
  • For a business that is properly using a social media information system, the system can
    13·1 answer
  • The ______ Works on a single variable or constant. *​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!