Witam napisałem program obliczający nwd 2 liczb tylko że za każdym razem wynik wynosi 0.
Co robie źle?
#include <stdio.h>
#include <stdlib.h>
int nwd(int a, int b)
{
int nwd=0;
do
{
if (a>b) a=a-b;
else b=b-a;
}
while (a!=b);
return a;
}
int main()
{
int a=0,b=0;
scanf("%d%d",&a,&b);
printf("%d",nwd(a,b));
return 0;
}