Wednesday, 1 Dec 2021
Category: number-theory

Given an integer N, find a prime number S such that all digits of N occur in a contiguous sequence. There may be multiple answers. Print any one of them.Example:Input: N = 42Output: 42013Explanation: 42013 is a prime and 42 occurs as a contiguous number in it. 15427 is also a correct answer.Input: N = […]

#include using namespace std;  long long ExtendedEuclidAlgo(    long long a, long long b,    long long& x, long long& y){        if (b == 0) {        x = 1;        y = 0;        return a;    }    else {                  long long x1, y1;        long long gcd            = ExtendedEuclidAlgo(b, a % b, x1, y1);                          x = y1;        y = x1 – floor(a / b) * y1;          return gcd;    }}  void linearCongruence(long long A,                      long long B,                      long long N){    A […]

Count occurrences of an element in a matrix of size N * N generated such that each element is equal to product of its indices Given two positive integers N and X, the task is to count the occurrences of the given integer X in an N-length square matrix generated such that each element of […]