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
List 2 positive impacts of cybersecurity.
kupik [55]

Answer:

Protection for your business and Increased productivity

Explanation:

This is because it ensures your employees aren't at risk from potential threats and, since there no virus, the computers will work well (not slow down)

7 0
3 years ago
Read 2 more answers
**PLEASE HELP**
ruslelena [56]
Normally, you might expect that anything related to Sodium and Chlorine is insanely dangerous and shares properties of both(B), but since the two are making a compound, that is not true. Compounds almost never share the properties of the elements they are made from. So your answer is D.
8 0
3 years ago
Whats difference between DCE AND DTE serial interface
harina [27]

DCE stands for data circuit-terminating, data communications, or data carrier equipment - this is a modem or more generally, a line adapter.

DTE stands for data terminal equipment which generally is a terminal or a computer.

Basically, these two are the different ends of a serial line.

7 0
3 years ago
Why computer manufacturers constantly releasing faster computers ?
DaniilM [7]

Answer:

do not copy word for word!!!!

Explanation:

The Computer manufacturers constantly releasing faster computers as in every month or in a year new technologies are discovered. ... By making the faster computers manufacturers want to earn much profit and they want to beat the competition. If the computer will be slow, it will take much time to open a file or to save a file.

7 0
3 years ago
Escribe 10 ejemplos de lo que consideras un byte
stira [4]

<u>Respuesta:</u>

Espero y te pueda ayudar: ).

4 0
3 years ago
Other questions:
  • Assume that a function named swapdoubles has been defined and is available for use in this exercise: that function receives two
    8·1 answer
  • A raised dot (ú) shows where the enter key was pressed. true or false.
    13·1 answer
  • What are the reasons why is it necessary to evaluate online sources and content?
    6·1 answer
  • Which of the following tasks can you perform using a word processor?
    12·1 answer
  • I have to writea piece of code to calculate the factorial of somewhat large numbers so the long long type won't suffize, so usin
    7·1 answer
  • Look at the following HTML form. Which description is correct? Please enter your discount code:
    13·1 answer
  • 20.
    15·2 answers
  • What can help narrow your search results when using the Index search feature in the Help menu?
    7·1 answer
  • Polynomial regression A common misconception is that linear regression can only be used to fit a linear relationship. We can fit
    11·1 answer
  • Location of a video or photoshoot is not important when it comes to preplanning the shoot
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!