From the course: C Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Challenge: Prime numbers

Challenge: Prime numbers - C Tutorial

From the course: C Essential Training

Challenge: Prime numbers

(beeping music) - For this challenge, you will write a program that calculates the first 25 prime numbers, that is, all the prime numbers under a hundred. A number is considered prime if it's a natural number, that is, a positive number with no fractional part. A prime number must be greater than one, so one is not a candidate, but two is. And it cannot be a product of two smaller natural numbers. Another way to say this is, its only factors are itself and one, or it can only be divided evenly by itself and one. This is a list of the first 25 prime numbers. Your results should match these numbers. The purpose of this challenge is for you to use your knowledge of C operators to choose the operators that make sense in this context. Expect this exercise to take about 15 minutes. It's fine if it takes longer or if you want to spend extra time experimenting and trying different approaches. My solution is in the next movie.

Contents