Amazon Interview Question

How would you find the common primes in two integers ?

Interview Answers

Anonymous

Feb 9, 2012

Compute the GCD of the two numbers using Euclid's algorithm. Prime factorise the GCD.

2

Anonymous

Mar 13, 2012

GCD(int j, int i){ //assume i>j while(j!=0){ int temp=i%j; int i=j; int j=temp; } return i; }