This is a place to discuss python. Here are two codes I made to find out the prime factors.
1 2 3 4 5 6 7 8 9 10 

1 2 3 4 5 6 

These may not be the best but are quite efficient. Share your code in the comments.
Also, make a program to find the HCF of two numbers(it probably requires the use of lists and I don't know much about lists).
Easy Math Editor
This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.
When posting on Brilliant:
*italics*
or_italics_
**bold**
or__bold__
paragraph 1
paragraph 2
[example link](https://brilliant.org)
> This is a quote
\(
...\)
or\[
...\]
to ensure proper formatting.2 \times 3
2^{34}
a_{i1}
\frac{2}{3}
\sqrt{2}
\sum_{i=1}^3
\sin \theta
\boxed{123}
Comments
Sort by:
Top Newestprogram to find the HCF of two numbers can be made using Euclid's algorithm
Log in to reply
It doesn't requires list but rather it requires recursion
Log in to reply
I've done it. A program to find the HCF of two numbers. It uses Euclid's Division Algorithm which is the same as finding the HCF using the long division method.
Log in to reply
You only need to check for factors upto $\sqrt{n}$ the factors over that are just $\frac{n}{\text{already known factors}}$, this can increase efficiency by quite a lot
Log in to reply
But $\sqrt{n}$ is float for most of the integers 'n' and the range loop is not accepting floats.
I reduced it to half by doing
Log in to reply
Try this instead
Log in to reply
Log in to reply
Yeah. Try
Log in to reply
I don't understand what you want to say
Log in to reply
You need only check for numbers up to $\sqrt{n}$!
Log in to reply
can you(anyone) suggest anything so that it does powers easily. Like I tried $5^{10} = 9765625$ in both the prime factor programs and the output was
Log in to reply
Check out this code, gives all prime factors and their multiplicity too
Log in to reply
It is good. I added this at the last in place of print(prime) to print each factor in a separate line
Log in to reply
@Jason Gomez Is there any function in python which finds the common items in two or more lists?
Log in to reply
Yes you can just use set conversion of both lists and then use intersection method to do so.
Log in to reply
Log in to reply
Log in to reply
Log in to reply
Log in to reply
Log in to reply
Log in to reply
Log in to reply
Log in to reply
Log in to reply