import java.util.Scanner; public class Quisora Ulam { public static void main (String args []) { Scanner sc = new Scanner (System.in); //read integer System.out.print ("Input N: "); int num =...


Explain how the number sequence is generated.


import java.util.Scanner;<br>public class Quisora Ulam {<br>public static void main (String args []) {<br>Scanner sc = new Scanner (System.in);<br>//read integer<br>System.out.print (

Extracted text: import java.util.Scanner; public class Quisora Ulam { public static void main (String args []) { Scanner sc = new Scanner (System.in); //read integer System.out.print ("Input N: "); int num = sc.nextInt () ; //print the Ulam sequence System.out.printın ("Ulam Sequence :"); //loop works till num is not 1 while (true) { if (num == 1) { System.out.print (num) ; break; //end the loop else { System.out.print (num+","); //even number if (num 2 == 0) { num = num / 2; else {//odd number num = 3 * num + 1; } } }

Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here