Language: C++

#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

bool isPrime(int a)
{
	bool result = true;
	for (int i = 2; i < sqrt(a); i += (i == 2 ? 1 : 2)) {
		if (i>3 && i % 3 == 0) continue;
		if (a%i == 0) {
			result = !result;
			break;
		}
	}
	return result;
}

int main()
{
	vector<int> prime;
	prime.push_back(2);
	for (int i = 3; i < 1000000; i += 2) {
		if (isPrime(i)) {
			prime.push_back(i);
		}
	}

	int a, d, n;
	for (cin >> a >> d >> n; a || d || n; cin >> a >> d >> n) {
		vector<int>::iterator prev = find(prime.begin(), prime.end(), a);
		if (prev == prime.end()) {
			prev = prime.begin();
		}
		for (int i = 0; i < n; a += d) {
			vector<int>::iterator answer = find(prev, prime.end(), a);
			if (answer != prime.end()) {
				prev = answer;
				i++;
			}
		}
		cout << a - d << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:50: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)'
   31 |                 vector<int>::iterator prev = find(prime.begin(), prime.end(), a);
      |                                              ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
                 from /usr/include/c++/14/bits/basic_ios.h:37,
                 from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:31:50: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   31 |                 vector<int>::iterator prev = find(prime.begin(), prime.end(), a);
      |                                              ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:36:60: error: no matching function for call to 'find(std::vector<int>::iterator&, std::vector<int>::iterator, int&)'
   36 |                         vector<int>::iterator answer = find(prev, prime.end(), a);
      |                                                        ~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   template argument deduction/substitution failed:
a.cc:36:60: note:   '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
   36 |                         vector<int>::iterator answer = find(prev, prime.end(), a);
      |                                                        ~~~~^~~~~~~~~~~~~~~~~~~~~~