Prime numbers are real numbers greater than 1 and only has two factors namely dividing the number 1 and itself. In other words, prime numbers are numbers divisible only divisible by 1 and itself. In programming we use the distribution modulus (MOD). For example, 11 is prime because it can only be divided by 1 and divided by 11. While 10 is not prime because it can be shared in addition to 1 and 10, number 10 also can be divided by 2 and 5. Examples of prime numbers are: 2, 3, 5, 7, 11, 17, 23, and so on.
For example the number entered is N, then N is prime if N can only be divided and divided 1 N itself. For example N = 15, then we should try to divide N is the number between 15 to 1 and 15 that is 2 s / d 14 (or N-1). If one division is successful, it is certainly not the 15 prime numbers, so instead of if there is no division is successful, 15 are prime numbers. For this example, 15 is prime, because 15 can be divided into 3 and 5.
Application in C + + program to determine the prime numbers are as follows:
Sunday, November 15, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment