Code Below:


import java.util.*;
class hailstone_sequence
{
    public static void main()
    {
        Scanner s=new Scanner(System.in);
        int n,a,sum=0,k=0,c=0;
        System.out.println("enter a no.");
        n=s.nextInt();
        System.out.print(n+",");
        while(n!=1)
        {
            if (n%2==1)
            n=n*3+1;
            else
            n=n/2;
            System.out.print(n+",");
        }
    }
}