+ 14
CODING CHALLENGE #2 !! - Algorithm that does prime factorisation!!
I am going to give you an example... 64... Is divided by 2 and 32, 2 is already prime so leave it for now... 32 can be divided in 4 and 8... 4 can be divided in 2 and 2, so lets leave these numbers... 8 can be divided in 4 and 2... In the end 4 can be divided in 2 and 2... We got 6 twos, so the prime factorisation of 64 is 2 to the power of 6 or 2**6... It can be done in any language!! No google or stackoverflow.com :)
21 Answers
+ 12
@Gami can u tell me if it could be done in HTML
+ 10
@Giannis nobody is going to input a number that big obviously...
+ 10
@Yash, @Nikolay They are correct, but you are late :/. @Gagan HTML is a markup language, so no xD
+ 9
Guys, all of them are correct! @Giannis yours doesn't include the * , which is a shame... However, I am going to give it to you! I like all of them, well done guys!!!
+ 8
Is this OK?Also tell me if theirsโ another way to do it.
https://code.sololearn.com/cwRX2Ofp3PAc/?ref=app
+ 8
A JS solution ๐
https://code.sololearn.com/WuQoPrPc80hl/?ref=app
+ 7
hmm
+ 6
I'll give it a try
+ 6
I'll give it a try when I get back home in a couple of hours.
+ 5
whats the problem,I domt know help me.
+ 3
it can be done for small numbers but not for all because the set of primes is infinite. state some limitations please
+ 3
@Giannis Tsirovasilis
Yea, yours is nice too.
Tip: You only have to go until and inclusive the square root of the number to check if a number is prime :)
(Do calculate it before you enter the for loop to prevent calculating it every iteration)
+ 3
@Dennis yeah i know but that would have problem if the number was 3 for example so because i was bored i let it like that xD thanks though
+ 3
https://code.sololearn.com/c8utFOgIbipg/?ref=app
Goes up to 2^64 - 1
+ 2
@Meharban this is not right.
+ 2
@Dennis nice one dennis. check mine too. just the way i print the numbers.
+ 2
@Meharban look at my code and check how i find that a number is prime.
+ 1