As I have solved many algorithm problem, either just out of interest or to prepare for interviews, I have realized that these basic math premises are quite handy. We have all learnt these in school/college etc. but we often forget these basics and do not write efficient algorithms. Feel free to suggest more to add to the list..
- Every whole number can be represented by the product of a unique combination of prime numbers. E.g. 48 = 2^4 x 3, 46 = 2 x 23
- To confirm if a number is a prime or not, it is enough to check if there exists a factor between 2 and the sqrt(number). No need to check until number-1.
- A factorion is an integer which is equal to the sum of factorials of its digits. There are exactly four such numbers:
No comments:
Post a Comment