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
When it comes to social media technologies and formal learning in the corporate environment, the only social media platform that
Andrew [12]

Ootions: TRUE OR FALSE

Answer: FALSE

Explanation: According to (Steer,2015) there are many platforms for learning and teaching purposes in corporate Organisations, they include PINTEREST,WIKI,GOOGLE+, LINKEDIN,TWITTER etc, The social media platforms are available for effective and efficient Communication and has been the main driving force for Businesses the world over.

These social media platforms have aided the growth and expansion of product marketing strategies and enhanced the over all business efficiency.

4 0
2 years ago
Name the design tool that can be used to establish a spatial hierarchy of the content
rewona [7]

Typography is a tool that can be used to establish a spatial hierarchy of the content.

6 0
3 years ago
Read 2 more answers
A software developer would utilize a(n) ________ to detail a compilation of hardware and software components to create a framewo
sweet [91]

A software developer would utilize an architectural design to detail a compilation of hardware and software components to create a framework for software development.

The term architectural design denotes the oftware architecture while the term non-architectural design denotes the detailed design. The architect draws the line between these two designs.

6 0
2 years ago
which field in the contact form is used to control the order in which contacts are displayed in the current view
Bond [772]

Answer: File As is used to control the order in which contacts are displayed in the current view

4 0
2 years ago
What is Relational Computerized Database
Anestetic [448]

Answer:

is a software used to maintain relational databases in a relational database software system

8 0
3 years ago
Read 2 more answers
Other questions:
  • Being tired has very similar effects on the body as what
    7·1 answer
  • Define the missing function. licenseNum is created as: (100000 * customID) + licenseYear. Sample output:
    10·2 answers
  • What does the hard disk drive do?
    9·2 answers
  • What is intellectual property?
    13·1 answer
  • A computer has 9850 processes and 172 of them where suspended while 276 were terminated.,explain why some of the processes where
    15·1 answer
  • QUESTION 16
    14·1 answer
  • Create a function names minElement() that takes an array of numbers as a paaramter and returns the min value of the array. The a
    9·1 answer
  • When would you insert a merge field?
    10·2 answers
  • Now the y0utube home screen is gone
    13·2 answers
  • Explain approaches of AI​
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!