====contoh pemrograman fibonacci===

public class fibonacci {
public static void main(String[]args){
int a=1,b=1;
int n = 20; // input deret fibonacci
System.out.print(a+” “);
for (int i=1;i<n;i++){
System.out.print(a+” “);
a=a+b;
b=a-b;
}
System.out.println();
}
}

 

===contoh pemrograman bilangan ganjil===

public class modulus_bilangan {
public static void main (String[] args){
for(int x=1; x<=20; x++){
System.out.println(x);
int total;
total= x % 2;
if(total==0){

}else{
System.out.println(“Ganjil”);
}
}
}
}