Computer Science, asked by anindyaadhikari13, 3 months ago

Display the prime factors of a number using 1 loop? Write in Java or Python. Show your output. ​

Answers

Answered by Oreki
4

Program:

 def prime_factors(number):

     i = 2

     while i * i <= number:

         if number % i:

             i += 1

         else:

             number //= i

             print(i, end=", ")

     if number > 1:

         print(f"{number}.")

   

 number = int(input("Enter a number - "))

 print(f"Prime factors of {number} - ", end="")

 prime_factors(number)

Attachments:

anindyaadhikari13: prime factors are 2 and 3 but prime factorisation is 2×3×2
RockingStarPratheek: The Question asks for only Prime Factors of a Number @Anindyaadhikari13 Bro, Not about Prime factorisation
RockingStarPratheek: Nice Answer @Oreki ! Keep it up :)
Oreki: Thanks!
anindyaadhikari13: but prime factors of 12 are 2 and 3.right? But the output is coming 2,2,3
RockingStarPratheek: Ya, That's Right ! Kindly Correct it @Oreki
anindyaadhikari13: Wait. I am asking again.
Oreki: I can't edit now, so you can report my answer and let someone else answer
anindyaadhikari13: You can ask any mod for edit.
Oreki: Well, I could append the outputs in a list and print only unique elements
Answered by akumar41864
0

Answer:

\huge\pink{\underline{\boxed{\mathbb{AnSwEr}}}}

AnSwEr

____________________________

scalar quantity in physics is one that can be described by a single element of a number field such as a real number, often accompanied by units of measurement.

A scalar is usually said to be a physical quantity that only has magnitude, possibly a sign, and no other characteristics.

_____________________________

Similar questions