Prime Number

Count of distinct integers belonging to first N terms of at least one of given GPs

Given two Geometric Progressions (a1, r1) and (a2, r2) where (x, y) represents GP with initial term x and common…

Read More

Find longest subarray with Prime sum in given Array

#include using namespace std;  void SieveOfEratosthenes(    vector& prime, int total_sum){                    for (int i = 0; i

Find a prime number S containing given number N in it

Given an integer N, find a prime number S such that all digits of N occur in a contiguous sequence.…

Read More

Generate a sequence with product N such that for every pair of indices (i, j) and i < j, arr[j] is divisible by arr[i]

#include using namespace std;  vector primeFactor(    int N){        vector v;          int count = 0;          while (!(N % 2)) {                  N >>= 1;        count++;    }          if (count)        v.push_back({ 2, count });          for…

Read More

2 Keys Keyboard Problem

2 Keys Keyboard ProblemGiven a positive integer N and a string S initially it is “A”, the task is to…

Read More

Largest Prime Number possible from a subsequence of a Binary String

#include #include using namespace std;  bool isPrime(int x){    if (x

Find the array element having equal count of Prime Numbers on its left and right

#include using namespace std;  int findIndex(int arr[], int N){            int maxValue = INT_MIN;          for (int i = 0; i < N; i++) {        maxValue…

Read More

Segregate Prime and Non-Prime Numbers in an array

import java.io.*;import java.lang.*;import java.util.*;public class GFG {            static boolean isPrime(int n)    {                if (n

Number which is co-prime with all integers from a given range

Number which is co-prime with all integers from a given rangeGiven two positive integers L and R, the task is…

Read More