Link to the question is - spoj question I have tried solving the question by this approach - The number of pairs in N range = Number of pairs in N-1 range + some new pairs. But I don't know what else optimisation should be done here to avoid TLE....

This is the pseudo code for calculating integer factorisation took from CLRS. But what is the point in calculating GCD involved in Line 8 and the need for doubling k when i == k in Line 13.? Help please....

I am trying to write a function to find the gcd of 2 numbers, using Euclid's Algorithm which I found here. From the larger number, subtract the smaller number as many times as you can until you have a number that is smaller than the small number. (or without getting...

i am new to java and need help please. My while loop isn't working. It doesn't execute anything other than count. For this question I need to make fraction class that has mutator and accessory methods. Then I have to make the numerator and denominator to lowest form so i...

How to find LCM of {1, 2, ..., n} where 0 < n < 10001 in fastest possible way. The one way is to calculate n! / gcd (1,2,.....,n) but this can be slow as number of testcases are t < 501 and the output should be LCM ( n!...

Every time I use the Euclid method for checking if two numbers are co-prime. But there is one solution which has used this code to check for co-primeness, and the time taken by this was much faster than the Euclid method: (source) private static boolean isCoprime(long u, long v) {...