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]
2 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]2 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
The process of making raw materials into a finished product is known as
Olin [163]
1.) Business Engineering or Manufacturing :)
<span />
6 0
2 years ago
Read 2 more answers
HELP PLEASE
GREYUIT [131]

Answer:

D, storyboard

Explanation:

5 0
3 years ago
You have a 20-bit network part and a 4-bit subnet part. How many hosts can you have per subnet?
Ymorist [56]

Answer:

tiddies

Explanation:

sukk

3 0
3 years ago
9. Government and corporate officials concerned about security threats do not bring their own cell phones or laptops when travel
tatuchka [14]

Answer:

True

Explanation:

It is known as Don-Not-Carry rules are implemmented to avoid

-Unauthorized full disk copies (it have been made while the laptop owner was out of the hotel room on overseas travel)

-Laptops steals

- Monitoring by third parties of wireless using.

3 0
3 years ago
What are they ethical issues with Drones?
guajiro [1.7K]
They may invade privacy rights of air space and be used for other unintended acts such a bombings and espionage
4 0
2 years ago
Other questions:
  • What command in windows re gives you the opportunity to manage partitions and volumes installed on the system?
    7·1 answer
  • How to get out of the verify your identity page on a dell laptop because it won’t let me
    13·1 answer
  • Suppose that your application uses a loop that isn't producing the intended results. The best way to analyze what’s going on in
    13·1 answer
  • What is the output of the code snippet given below?string s = "abcde";int i = 1;while (i &lt; 5){ cout &lt;&lt; s.substr (i, 1);
    11·1 answer
  • Which is not a factor that leads to technological advancement?
    8·1 answer
  • The file descriptor stderr is represented by the number ____.
    6·1 answer
  • What will you see on the next line?<br> &gt;&gt;&gt;int(12.8)<br> ___
    15·1 answer
  • What was the name of first computer?
    14·1 answer
  • Write a Coral program using integers userNum and x as input, and output userNum divided by x four times.
    7·1 answer
  • what impact of information communication technology have on the environment about electronic waste, use of electricity?​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!