// solve with C++// please add comment// please make sure the program will run1)Create a random 2000-digit number. Find the fourteen adjacent digits that have the greatest product. Output the digits...

1 answer below »
// solve with C++// please add comment// please make sure the program will run1)Create a random 2000-digit number. Find the fourteen adjacent digits that have the greatest product. Output the digits that create this number.
For instance, in the number 9845921 the numbers with two adjacent numbers with the greatest product are 9X8 = 72.








2)Create a random 2000-digit number and store it in a file. Read the number from the file and find the smallest number within our larger number
that contains at least every digit. For instance,149485420251367 contains every digit, but 94556780231 is a smaller number that contains every
digit.






3)Find the sum of all the numbers which are equal to the factorial of all their digits (e.g. 145 = 1!+4!+5!)
4)he number 197 is a circular prime because all rotations of the digits 197, 971, and 719 are prime. Find the total of all circular primes that
are three, four, or five digits long. We will only count the lowest of the rotations - in other words only count 197 - not 197, 971, and 719.



// solve with C++ // please make sure the program will run 1) Create a random 2000-digit number. Find the fourteen adjacent digits that have the greatest product. Output the digits that create this number. For instance, in the number 9845921 the numbers with two adjacent numbers with the greatest product are 9X8 = 72. 2) Create a random 2000-digit number and store it in a file. Read the number from the file and find the smallest number within our larger number that contains at least every digit. For instance,149485420251367 contains every digit, but 94556780231 is a smaller number that contains every digit. 3)Find the sum of all the numbers which are equal to the factorial of all their digits (e.g. 145 = 1!+4!+5!) 4) he number 197 is a circular prime because all rotations of the digits 197, 971, and 719 are prime. Find the total of all circular primes that are three, four, or five digits long. We will only count the lowest of the rotations - in other words only count 197 - not 197, 971, and 719.
Answered Same DayAug 16, 2021

Answer To: // solve with C++// please add comment// please make sure the program will run1)Create a random...

Kshitij answered on Aug 16 2021
151 Votes
C++/ques1.cpp
C++/ques1.cpp
# include
# include
# include
# include
# include
# include
# includeomanip>
# include
# include
# include
# include
# include
# include
# define modValue 1e9 + 7
# define ll long long int
# define lld long double
//# define cin ios_base::sync_with_stdio(false);cin.tie(NULL); cin
using namespace std;
int main() {
    // generate a string of digits of length 2000
    string s = "";
    int t = 2000;
    while (t--) {
        // by using random generate digit 1-9
        int k = 1 + rand() % 9;
        s += to_string(k);
    }
    map> mp;
    // use to store product with numbers
    for (int i = 1; i < s.size(); i++) {
        int a = s[i - 1] - '0';
        int b = s[i] - '0';
        mp.insert({a * b, {a, b}});
    }
    int ts = mp.size();
    int pk = ts - 14;
    int cc = 0;
    cout << "product" << "   " << "first Number       " << "second Number" << endl;
    // finding greatest 14 numbers 
    for (auto i : mp) {
        if (cc >= pk) {
            int k = i.first;
            auto no = i.second;
            cout << k << "                " << no.first << "               " << no.second << endl;
        }
        cc++;
    }
    return 0;
}
C++/ques2.cpp
C++/ques2.cpp
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
# include
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here