How do I do this?

I got a bit confused with this, I don't know how to do the prime thing, the one who helps me will get 5 cycles!

**Voters**

Ask coding questions

How do I do this?

I got a bit confused with this, I don't know how to do the prime thing, the one who helps me will get 5 cycles!

Have you searched for an answer using a search engine? If you do you will find many examples. Give it a go and save your 5 cycles.

@malvoliothegood I am not sure what is this called so I don't know what to search

@NZHacker808 Try the following search term: "C++ finding prime numbers" - include the quote marks. The first result I get looks promising. Here is the URL that I get when using the DuckDuckGo search engine: https://duckduckgo.com/?t=ffab&q=%22C%2B%2B+finding+prime+numbers%22&ia=web

@malvoliothegood OK I will try that!

@malvoliothegood Good I got how they did it!

@NZHacker808 Looks like you found a solution. A tip: your loop counter does not need to increment in value until it is the same as the number that you are testing. It only needs to go halfway. Think about why this is. Here is a fork of your program that encapsulates the prime finding code in a function: https://repl.it/@malvoliothegood/Prime-checker

@malvoliothegood That is very helpful! Upvoted :)

@NZHacker808 Thanks. By encapsulating the prime finding in a function your program can be more robust. For example you can test out any number of numbers using a

forloop.@malvoliothegood OK