There is a problem calculating d in this program and it iscausing problems with the rest of the code. I believe the problemis in the function ExtendedEuclidAlgGCD. Below is my code and thecurrent output
#include <iostream>
#include <cmath>
#include <assert.h>
using namespace std;
//Question 1
int EuclidAlgGCD(int a, int b)
{
int div=1, i=1;
while (i <= a && i <=b)
{
if ( a%i==0 && b%i==0)
div=i;
i++;
}
return div;
}
int ExtendedEuclidAlgGCD(int a, int b, int &s, int&t)
{
int div=EuclidAlgGCD(a,b);
t=a/div;
s=b/div;
return (div);
}
//Question 2
int mod (int a, int b)
{
int mod=0;
if (a < 0)
{
mod=(-1)*a*b+(a);
if
OR
OR