+ 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 :)

12th Apr 2017, 2:41 PM
Gami
Gami - avatar
19 Antworten
12th Apr 2017, 3:49 PM
Giannis Tsirovasilis
Giannis Tsirovasilis - avatar
+ 12
@Gami can u tell me if it could be done in HTML
12th Apr 2017, 4:13 PM
Siddharth
Siddharth - avatar
+ 10
@Giannis nobody is going to input a number that big obviously...
12th Apr 2017, 2:43 PM
Gami
Gami - avatar
+ 10
@Yash, @Nikolay They are correct, but you are late :/. @Gagan HTML is a markup language, so no xD
12th Apr 2017, 7:11 PM
Gami
Gami - avatar
+ 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!!!
12th Apr 2017, 7:09 PM
Gami
Gami - avatar
+ 8
Is this OK?Also tell me if theirs​ another way to do it. https://code.sololearn.com/cwRX2Ofp3PAc/?ref=app
12th Apr 2017, 3:12 PM
Meharban Singh
Meharban Singh - avatar
12th Apr 2017, 5:20 PM
Nikolay Nachev
Nikolay Nachev - avatar
+ 7
hmm
12th Apr 2017, 2:42 PM
Theprogrammers
Theprogrammers - avatar
+ 6
I'll give it a try
12th Apr 2017, 3:06 PM
Sachin Artani
Sachin Artani - avatar
+ 6
I'll give it a try when I get back home in a couple of hours.
12th Apr 2017, 3:26 PM
Nikolay Nachev
Nikolay Nachev - avatar
+ 5
whats the problem,I domt know help me.
12th Apr 2017, 3:20 PM
Meharban Singh
Meharban Singh - avatar
+ 3
it can be done for small numbers but not for all because the set of primes is infinite. state some limitations please
12th Apr 2017, 2:43 PM
Giannis Tsirovasilis
Giannis Tsirovasilis - avatar
+ 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)
12th Apr 2017, 3:56 PM
Dennis
Dennis - avatar
+ 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
12th Apr 2017, 3:57 PM
Giannis Tsirovasilis
Giannis Tsirovasilis - avatar
12th Apr 2017, 5:28 PM
Dennis
Dennis - avatar
+ 2
@Meharban this is not right.
12th Apr 2017, 3:18 PM
Giannis Tsirovasilis
Giannis Tsirovasilis - avatar
+ 2
@Dennis nice one dennis. check mine too. just the way i print the numbers.
12th Apr 2017, 3:50 PM
Giannis Tsirovasilis
Giannis Tsirovasilis - avatar
+ 2
@Meharban look at my code and check how i find that a number is prime.
12th Apr 2017, 3:53 PM
Giannis Tsirovasilis
Giannis Tsirovasilis - avatar
14th Apr 2017, 3:19 AM
Daniel Chin