David W. answered 11/18/17
Tutor
4.7
(90)
Experienced Prof
First, determine whether the sequence should have been the squares of 1 and the prime numbers.
Then, determine what N=2800 means: count of terms to be output; largest prime; number of primes; ...
Break up the problem into two easier problems:
(a) find the prime numbers
Start simply (up to 10) and use definition (not evenly divisible by any smaller integer 2 or more). There is a MOD function in most programming languages. If not use integer division.
(b) determine whether a number has a 9 digit. Again, use integer division by 10 and the MOD function in a loop.
Once both programs work, put them together. It is important to take "small steps" to avoid "bugs" and waste your time resolving them.
Only then, improve speed or accuracy. Make the number 100 instead of 10. Only test divisors up to (the number/2). Only check prime divisors (this means keeping a table of primes found).
The biggest challenge is likely what 2800 means. It may require the use of integers larger than the programming language allows.
Any typical PC is so very fast (and people are so very slow) that efficiency considerations are actually wasteful.