Thursday, August 25, 2016

UVA 160 - Factors and Factorials solution(Only hints)

problem link-click here

at first glance you may think that you have to find the factorial of the given N then the prime factors but it's not like that.. just find the prime factorization of number 1 to N and count the primes like guess 5! which can be written as,
                              5! = 120 = 2*2*2*3*5
again if we assume prime factor of 5 is 5, 4 is 2*2 , 3 is 3, 2 is 2.... so we get 2*2*2*3*5 from here so both the facts are same. but the 2nd one is less time consuming. follow the output format. you need to find primes within 100 because it will be enough for this problem.

No comments:

Post a Comment