So far each function had one small job, and the problem told you what it was. Longer problems don't: they say what the answer is, and you decide how to split the work. That splitting is called decomposition, and it is the most useful habit you can pick up this week.
Top-down: write main first
Here is a problem:
A number is a double prime if it is prime and the sum of its digits is prime too. You are given n numbers (1 ≤ n ≤ 1000, each between 1 and 10⁶). Print the double primes in the order they are given, and then how many there were.
Read the statement and underline each thing that has to be checked or
computed: is it prime, the sum of its digits, is it a double prime.
Each becomes a function. Then write main as if those functions already
existed:
main is now short enough to check at a glance. What is left are three small
problems, each of which can be written and tested alone.
The whole program:
For the numbers 23 13 29 31 47 89 10 it prints 23 29 47 89 and 4. isDoublePrime
is just the two helpers combined — a function built from functions. Step through
one number and watch main hand the work out: