Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- std::string get_concatenated_primes()
- {
- unsigned int base, test, cap=1000, prime=0;
- std::string plist;
- for (base=0; base < cap; ++base)
- {
- for (test=2; test < base; ++test)
- {
- if (base % test == 0)
- break;
- else
- {
- prime=1;
- }
- }
- if (prime == 1 && plist.length() < 1000)
- {
- plist += base;
- }
- }
- return plist;
- }
- std::string get_slice_of_5(const std::string concat_primes, const unsigned int n)
- {
- std::string slice;
- slice = concat_primes.substr (n, 5);
- return slice;
- }
- int main()
- {
- unsigned int n;
- while(std::cin >> n)
- {
- std::string concat_primes = get_concatenated_primes();
- std::cout << get_slice_of_5(concat_primes, n) << std::endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement