How to check if a number is prime or not?

The Enigma of Prime Numbers

11/06/2017

Rating: 4.45 (7460 votes)
Table

The Enigma of Prime Numbers

Prime numbers, those elusive integers greater than one that are only divisible by one and themselves, form the bedrock of number theory. Their seemingly erratic distribution has puzzled mathematicians for centuries, leading to profound questions about the very fabric of arithmetic. While we can readily identify if a specific number is prime through its factors, understanding the overarching pattern and behaviour of primes within the infinite expanse of natural numbers presents a significant challenge.

How to identify if a number is not a prime number?

What Exactly is a Prime Number?

At its core, a prime number is a natural number that has exactly two distinct positive divisors: 1 and the number itself. Numbers that have more than two divisors are known as composite numbers. For instance, 7 is prime because its only divisors are 1 and 7. Conversely, 6 is composite as it can be divided by 1, 2, 3, and 6. The number 1 is neither prime nor composite.

The Infinite Nature of Primes: A Mathematical Paradox?

One of the most remarkable discoveries in mathematics is that the sequence of prime numbers is infinite. Euclid's proof, dating back over two millennia, elegantly demonstrates this fact. However, the *distribution* of these primes is far from uniform. They appear somewhat randomly scattered amongst the natural numbers, leading to the question: can we predict where the next prime will appear?

Consider the concept of generating a number 'A' by summing 1 with the product of all primes up to a certain prime 'P'. If we imagine 'P' tending towards infinity, 'A' would also tend towards infinity. This leads to a curious thought experiment: could infinity itself be a prime number? Similarly, if we consider the factorial of a natural number 'n', denoted as F(n) (the product of all natural numbers up to 'n'), as 'n' tends to infinity, F(n) also tends to infinity. However, F(n) plus 1 is always divisible by any prime less than or equal to 'n'. This suggests that as 'n' approaches infinity, F(n) + 1 would not be prime, leading to a potential contradiction regarding infinity's primality.

These are, however, considered indeterminacies within the theory of limits, akin to the behaviour of functions like sin(x) as x approaches infinity. While these abstract scenarios highlight the complexities, they don't provide a definitive answer to the nature of infinity in relation to primality.

Statistical Analysis of Prime Distribution

Despite the inherent randomness, mathematicians have sought to find patterns and statistical regularities in the distribution of prime numbers. One such approach involves analysing the frequency of primes within intervals of natural numbers.

Let's outline a strategy for this statistical analysis:

  1. Choose a positive integer, N, as an upper limit for our analysis.
  2. For each natural number 'n' from 2 up to N:
    • Count the number of primes less than or equal to 'n'. Let this count be denoted as P_counter.
    • Calculate a statistical factor, 'f', by dividing P_counter by 'n'. This 'f' represents the relative frequency of primes up to 'n'.

While this can be done manually for small values of N, computational resources are essential for larger datasets. The provided MATLABĀ® script illustrates how this analysis can be implemented. The script systematically iterates through numbers, identifies primes by checking for divisors, and calculates the relative frequency of primes.

MATLABĀ® Script for Prime Number Analysis:

% |PRIME NUMBER ANALISYS| % For run in Matlab platform. % Memory allocation for matrix: Number = zeros(100000, 5); Number(1,1)=1; %{ Column 1 natural numbers set of 1 until N ; column 2: counter numbers of divisors for each in column 1; column 3: store TRUE or FALSE, if prime ou not prime respectively; column 4: store absolute frequence of primes in subset of each number in column 1; column 5: store relative frequence of primes in subset of each number in column 1. %} disp('Starting...'); % only a information. % User input: prompt = {'Enter a natural number for analisys:'}; dlg_title = 'User Input'; num_lines = 1; defaultans = {'1000'}; N = str2double(inputdlg(prompt,dlg_title,num_lines,defaultans)); P_counter = 0; % counter inicialization for statistic. % Searching for primes. for i = 2:N Number(i,1)= Number(i-1,1)+1; % Sequence 1 to N. for j=1:i % sub sequence for search. Test = mod(Number(i,1),Number(j,1)); if Test == 0 % found divisor. Number(i,2)= Number(i,2) +1; end if Number(i,2)>2 % when rule of primes will violated. Number(i,3) = false; else Number(i,3) = true; end if Number(j,3) == true P_counter = P_counter +1; % counter update for statistic. end end if Number(i,2)==2 Number(i,4) = true; % prime atribute. else end Number(i,5)= Number(i,4)/Number(i,1); % create statistic. P_counter=0; end % End of work for N natural numbers % Ploting disp('Go ploting...') for i=1:N plot(Number(i,1),Number(i,5),'Marker','.','Color','blue') grid 'on'; hold on; xlim([0 N]) end disp('End of task.') % End of program. 

Interpreting the Results: The Prime Number Theorem

When this statistical analysis is performed for increasing values of N (e.g., 1000, 5000, 10000, up to 100000), a clear trend emerges. The relative frequency of primes ('f') tends to decrease and appears to approach zero as 'n' grows larger. This observation is consistent with the Prime Number Theorem, which states that the distribution of primes can be approximated by the logarithmic integral function.

How do you know if a number is prime?
The primes serie is ilimited, but we only know if certain number is prime if we verify it through its factoring. However, we can create a prime number A resulting of the sum of 1 with the result of multiplication of all primes until certain prime P. For example:

By calculating the angular coefficient ('m') between points on the plot of 'f' against 'n' for different intervals, we can observe that the absolute values of 'm' generally decrease as 'n' increases. This suggests that while primes become less frequent relative to all numbers, their incorporation into the composite number system doesn't entirely halt their appearance. The rate at which new primes emerge slows down, but they continue to be added to the infinite sequence.

The plot of 'f' against 'n' visually suggests that the x-axis might be an asymptote for 'f'. However, because the sequence of primes is infinite and appears to have a hyperbolic behaviour in its distribution, 'f' will likely never settle on a constant value, meaning 'm' will always be different from zero in a deterministic sense. This implies that primes are essential components of the number system, but their distribution's nature prevents them from defining infinity as a prime number in a simple, deterministic way.

Key Takeaways:

  • A prime number is a natural number greater than 1 with only two divisors: 1 and itself.
  • The sequence of prime numbers is infinite.
  • The distribution of primes is not uniform, exhibiting a seemingly random pattern.
  • Statistical analysis reveals that the relative frequency of primes decreases as numbers get larger.
  • The Prime Number Theorem provides an approximation for the distribution of primes.

Frequently Asked Questions:

How do you know if a number is prime?

To determine if a number is prime, you can test for divisibility by all integers from 2 up to the square root of that number. If none of these numbers divide it evenly, then the number is prime. For larger numbers, more advanced primality tests are used.

What is the mystery of prime numbers?

The mystery lies in their unpredictable distribution. While we know they are infinite, predicting their exact location within the natural numbers remains a significant challenge in mathematics.

How to identify if a number is not a prime number?

If a number greater than 1 can be divided evenly by any integer other than 1 and itself, it is not a prime number; it is a composite number.

What is the difference between a prime and a co-prime number?

A prime number is a natural number greater than 1 divisible only by 1 and itself. Co-prime numbers (or relatively prime numbers) are two or more numbers whose greatest common divisor is 1. For example, 7 is prime. 8 and 9 are co-prime, but neither is prime.

If you want to read more articles similar to The Enigma of Prime Numbers, you can visit the Automotive category.

Go up