In this paper, a new method based on machine learning methods is used to find prime numbers. In this way, by training a regression model using the sum of the previous prime numbers, the next prime number can be calculated with a very small error. Even the next one hundred prime numbers can be guessed. The error of this calculation is very small and this error is alternating (sine or cosine) and it becomes zero in some places. Therefore, it can be said that due to zero error, the next prime number must exist and this theorem proves the infinity of prime numbers.