Hi ,I want to go back after the else to the if statement(step2),how can I do it

public class main {

	public static void main(String[] args) {
	  gcd(12,23);
	}
public static void gcd(int m,int n){
	int uPrime=1;
	int vPrime=0;
	int u=0;
	int v=1;
	int mPrime=m;
	int nPrime=n;
	int counter=0;
	if(mPrime%nPrime==0)//step2
	{
		 System.out.println("Result "+(u*m+v*n));
		 System.out.println("Result "+nPrime);
		 System.out.println("Counter "+counter);
	}
	else
	{
		
		int temp1=u;
		int temp2=v;
		u=uPrime-(mPrime/nPrime)*u;
		v=vPrime-(mPrime/nPrime)*v;
		uPrime=temp1;
		vPrime=temp2;
		int r=mPrime%nPrime;
		mPrime=nPrime;
		nPrime=r;
		counter++;//redirect back to step 2
		
	}
	}
}

You can use while (true) {...} condition. And itself modify the condition out of the loop.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.