Faktor pembagi terbesar (FPB) is the largest bialangan positive integers that can divide up the two numbers. To find the gcd can use a simple way (factor trees), factorial and the Euclidean algorithm.
How to determine the FPB is to look at factors such numbers and using prime factorization. Which he takes the rank is the lowest rank.
Example :
Find the gcd of 6 and 8 by looking at the factors in these numbers!
Factor of 20 = {1, 2, 3}
Factor of 30 = {1, 24}
Thus, the gcd of 6 and 8 is 2
Now we can make the algorithm to make the program determines the gcd of two numbers are entered. Suppose we inputkan m and n. m and n are not negative integers. To find the FPB we must determine the greatest value, for example (m> = n), then the algorithm to find gcd ( algoritma Euclidean) are as follows (with pseudocode):
1.If n = 0 then m is gcd (m, n), but if n ≠ 0 go to step 2.
2.Divide m by n and let r be the remainder.
3.Change the value of m with a value of n and n values with the values of r, and then reset back to step 1.
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 + +) :