/**
* @(#)Sequence.java
*
*
* @author Satria Wibawa
* @special thanks for Anshori
* @version 1.00 2009/11/10
*/
import javax.swing.*;
public class Sequence {
/**
* Creates a new instance of
Sequence
.*/
public Sequence() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int n,m,besar=1;
n = Integer.parseInt(JOptionPane.showInputDialog("Masukkan Angka: "));
System.out.println("Angka anda: "+n);
System.out.println("Inilah Barisnya");
System.out.print(n+" ") ;
while(n!=1){
if(n>besar)
besar=n;
m = n%2;
if (m==1)
n=3*n+1;
else
n=n/2;
System.out.print(n+" ") ;
}
System.out.println();
System.out.println("Angka yang terbesar :"+besar);
}
}
buat apa ni sat ?
BalasHapus