菜鸟练手的小程序,发现while变成死循环,不明原因,求高手解惑

一个验证质数的小程序

 // ConsoleApplication2.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "math.h"
//验证x是否为质数


int main()
{
    int x, A=2, B=2, FLAG;    //A是第一个试验因数,B是第二个试验因数
    printf("The number: ");
    scanf_s("%d",&x);   //输入需验证数字




    while ( (A * B) <= x )        //这层用来改变第一个试验因数    
    {
        while ( (A * B) <= x );  //这层用来改变第二个试验因数
        {
            if ( (A*B) == x )
            {
                FLAG = 0;goto END;
             }
            else if ( (A*B) < x )
                B = ( B + 1 );
            else 
                goto NEXT;
          }

    NEXT:
        A = (A + 1) ; B = A;
     }






  END:
      if (FLAG = 0)
      {
          printf("It's not a prime number/n");
          printf("The factors that had been found are:%d AND %d", A, B);
      }
     else
          printf("It's a prime number");






 return 0;

}

打断点,逐步去调试,肯定是条件一直符合

while ( (A * B) <= x ); //这层用来改变第二个试验因数
这里多加了一个; 把它去掉

最外层while、else、next都没用

验证质数的方法:
质数的定义(理解):只能被1和本身整除的数。
int a=输入的数
int b=0;//接收被整除的次数
for(int i=a;a>=1;a--)
{
if(a%i==0)
b++;
}
if(b==2)
质数
else
非质数