Solving Mathematical Programming Questions
Important Concepts :
Important Concepts :
- Prime numbers - Number is prime if it can be divided by exactly 2 number 1 and itself.
- 1 is not prime as its not divided by 2 numbers
- Prime numbers are +ve only.
- Eg : 1, 2, 3, 5, 7 ...
- 2.. n if i divides n then n is not prime
- Chk only till sqrt(n) that should be enough
- Cofactors - b= n/a ; n=b*a
- cofactors of 36 - {1,36}{2,18}{3,12}{4,9}{6,6}{12,3}[18,2}{36,1}
- Factors of n
- eg : 12 - 1, 2, 3, 4, 6,12
- eg : 17 - 1,17 - n is prime Hence it has only 2 factors
- all numbers are divisible by 1 and itself
- hence chk from 2 - n/2
- Running time = o(n)
- Improvising using the principle of cofactors - it enough to chk 1 to sqrt(n)
- o(sqrt(n)
- Now based on co factors rule if we get a then n/a is also divisible by n if i!=sqrt(n)
Comments
Post a Comment