Prime Numbers: Determining the Type A Numbers
In the discussion this time I want to discuss the issue of primes. What is a prime number? Prime number is a positive integer more than one and the number is no trace if divided by one and the number itself. From these definitions we can make inferences primes are numbers that are only produced no trace of value if divided by two times, divided by one and the number itself. Immediately, in the example algorithms and programs. Then we can make the algorithm as follows :
Algoritma Prime Numbers
{Specifies the type of an input number, primed or not primed}
Deklarasi
a : integer (inialisasi)
x : integer (input)
Deskripsi
Read (x)
a <-- 0
for 1 to x do {
if (x % i == 0) then a++
}
if (a == 2) then write (“bilangan prima”)
else then write (“bukan bilangan prima”)
Writing functions in a program like this (in C + +) :
For a complete C + + program you can download here dyas sembilanpoepoeh.cpp
For a complete Java program you can download here dyas sembilanpoepoeh.java
Jadilah yang pertama mengomentari
Post a Comment