为什么这个程序停不下来?

#include <stdio.h>

int CommonFactors(int a,int b)
{
static int i=0;
int c=0;
for(int k=b; k>=1; k--)
{

    if(a%k==0 && b%k==0)
    {
       /* if (c==i)
        {
            i++;
            return k;
        }
        c++;*/
        return k;

    }
    
}
return -1;

}

int main()
{

int sub;

while ((sub = CommonFactors(100, 50)) > 0)
{

    static int counter = 1;

    printf("Common factor %d is %d\n", counter++, sub);

}

return 0;

}

main函数为什么用while,不应该是if吗