Number Finder

Joined
Sep 21, 2022
Messages
226
Reaction score
36
You need a prime test function. For small numbers, a modulo test inside a loop is good enough. Before you code it, have a look in your math library, it might already exist.

To test if a number has 2 as one of its digits, convert the number into a string, then search for a "2" inside the string.

A list of prime numbers that contain a 2 is not something where you can apply a simple formula. You need a loop, and it will slow down the higher you go.

If you are trying to generate a list, and you suspect there is a formula, generate the first 7 or so numbers by hand, then type them into the online encyclopedia of integer sequences. There's a good chance that someone has discovered it. Great web site.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,219
Messages
2,571,125
Members
47,731
Latest member
PasqualePf

Latest Threads

Top