Posts

Showing posts with the label Number Theory

Some Math / Number Theory Tricks

1#    Using Logarithms to Find Number of Digits in Large Numbers 2#   A number N can be represented by the difference of the square of two numbers that means  it is possible to find two integers p and q  such that   N = p^2 - q^2 If N is Odd or N is divisible by 4.         If we named this type of number is a good number then       2.1# If two number A and B both are good number then the product of them are also must be a good number 3# If a array / sequence have N element then total number of subarray / contigious_subsequence is n(n+1)/2 <<<<<<<<<<<<<<<<<<<<<<<<<<<<**************>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

GCD (Greatest Common Divisor)

Image
Using Euclid's algorithm A much more efficient method is the Euclidean algorithm , which uses a division algorithm such as long division in combination with the observation that the gcd of two numbers also divides their difference. To compute gcd(48,18), divide 48 by 18 to get a quotient of 2 and a remainder of 12. Then divide 18 by 12 to get a quotient of 1 and a remainder of 6. Then divide 12 by 6 to get a remainder of 0, which means that 6 is the gcd. Note that we ignored the quotient in each step except to notice when the remainder reached 0, signalling that we had arrived at the answer. Formally the algorithm can be described as: gcd ( a , 0 ) = a {\displaystyle \gcd(a,0)=a} gcd ( a , b ) = gcd ( b , a m ...