Program untuk menghitung perkalian deret bilangan genap di Java
Contoh perkalian deret bilangan genap :
output:
2*4*6*8*10*12=46080
Coding
output:
2*4*6*8*10*12=46080
Coding
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package allaboutalgoritma;
import java.util.Scanner;
/**
*
* @author dimata005
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int i, j, min, jum;
boolean prima;
Scanner input = new Scanner(System.in);
System.out.print("Masukkan nilai batas awal: ");
min = input.nextInt();
j=2;
//System.out.print(2);//<<j;
for (i=2;i<=min;i=i+2)
{
if(i==2){
System.out.print(2);//<<j;
}else{
System.out.print(" * ");
System.out.print(i);//<<j;
j = j * i;
}
}
System.out.println("\t\t= "+j);//"\t\t= "<<jum<<endl;
}
}
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package allaboutalgoritma;
import java.util.Scanner;
/**
*
* @author dimata005
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int i, j, min, jum;
boolean prima;
Scanner input = new Scanner(System.in);
System.out.print("Masukkan nilai batas awal: ");
min = input.nextInt();
j=2;
//System.out.print(2);//<<j;
for (i=2;i<=min;i=i+2)
{
if(i==2){
System.out.print(2);//<<j;
}else{
System.out.print(" * ");
System.out.print(i);//<<j;
j = j * i;
}
}
System.out.println("\t\t= "+j);//"\t\t= "<<jum<<endl;
}
}
posting pula yang lain,
BalasHapuskalau ada yang minta baru aku posting, soalnya bingung mau posting apa.
BalasHapusthanks atas infonya yah gan.. :D
BalasHapusditunggu postingan bermanfaat berikutnya sob..
BalasHapuskalau dalam c++ gimana sob..
BalasHapustolong dibantu..
minta posting yang ada arraylist nya mas
BalasHapusMin masukan yang menggunakan c++
BalasHapus