I followed the steps of Euclid’s algorithm but I was stunned when a divide by zero problem appeared. I don’t know how it can happen. Answer The problem is with the below two lines. First statement will make a[0] as 0 since c is 0. Next statement will be 1/0.