0
I need to do a show that does the following :
• Start with an integer N
• If N is even, divide by 2;
• If N is odd, multiply by 3 and add 1;
• Repeat this new process with the new value of N, if N 1;
• Ends the process when N = 1.
Scanner NUM = new Scanner(System.in);
double numerox;
System.out.println("Digite um numero inteiro: ");
double NUM1 = NUM.nextDouble();
while ((NUM1 % 2 == 0) && (NUM1 != 1))
{
numerox = NUM1 * 2;
System.out.println(+numerox);
break;
That’s all I could do.
What can I do to create a variable that stores these numbers and then print them and show their sum?
I thought of creating a variable NUMX
but I don’t know if it’ll work.
I’m glad it worked out! ✌
– Van Ribeiro