304 North Cardinal St.
Dorchester Center, MA 02124

# Coprime Range CodeChef Solution

## Coprime Range CodeChef Solution in C++17

``````
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define ll 				long long int
#define ld				long double
#define mod             1000000007
#define inf             1e18
#define endl			"\n"
#define pb 				emplace_back
#define vi              vector<ll>
#define vs				vector<string>
#define pii             pair<ll,ll>
#define ump				unordered_map
#define mpa 				make_pair
#define pq_max          priority_queue<ll>
#define pq_min          priority_queue<ll,vi,greater<ll> >
#define ff 				first
#define ss 				second
#define mid(l,r)        (l+(r-l)/2)
#define loop(i,a,b) 	for(int i=(a);i<=(b);i++)
#define looprev(i,a,b) 	for(int i=(a);i>=(b);i--)
#define log(args...) 	{ string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define logarr(arr,a,b)	for(int z=(a);z<=(b);z++) cout<<(arr[z])<<" ";cout<<endl;
#define token(str,ch)	(std::istringstream var((str)); vs v; string t; while(getline((var), t, (ch))) {v.pb(t);} return v;)
vs tokenizer(string str,char ch) {std::istringstream var((str)); vs v; string t; while(getline((var), t, (ch))) {v.pb(t);} return v;}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cout << *it << " = " << a << endl;
err(++it, args...);
}
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void file_i_o()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

int modularExponentiation(int x,int n,int M)
{
if(n==0)
return 1;
else if(n%2 == 0)        //n is even
return modularExponentiation((x*x)%M,n/2,M);
else                             //n is odd
return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

}
int prime[1000006]={0};
void primes()
{
loop(i,0,1000005)
{
prime[i]=0;
}
prime[1]=1;
prime[0]=1;
for(int i=2;i*i<=1000005;i++)
{
if(prime[i]==0)
{
for(int j=i*i;j<=1000005;j+=i)
{
prime[j]=1;
}
}
}
}
int main(int argc, char const *argv[]) {
file_i_o();
int t;
cin>>t;
primes();
while(t--)
{
int l,r;
cin>>l>>r;
int ans;
for(int i=r+1;;i++)
{
if(prime[i]==0)
{
ans=i;
break;
}
}
cout<<ans<<endl;
}
return 0;
}``````

## Coprime Range CodeChef Solution in C++14

``````
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define Time cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
#define pb push_back
#define mp make_pair
#define line cout << endl;
#define ff first
#define ss second
#define vi vector<int>
#define no cout << "NO" << endl;
#define yes cout << "YES" << endl;
#define printv(v)                      \
for (int i = 0; i < (v.size()); i++) \
{                                    \
cout << v[i] << " ";               \
}                                    \
line;
#define onesbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define sp(x, y) fixed << setprecision(y) << x
#define w(x) \
int x;     \
cin >> x;  \
while (x--)
#define tk(x) \
int x;      \
cin >> x;
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#ifndef ONLINE_JUDGE
#define debug(x)     \
cerr << #x << " "; \
_print(x);         \
cerr << endl;
#else
#define debug(x)
#endif
template <class T>
void _print(T t)
{
cerr << t;
}

template <class T, class V>
void _print(pair<T, V> p)
{
cerr << "{";
_print(p.ff);
cerr << ",";
_print(p.ss);
cerr << "}";
}

template <class T>
void _print(vector<T> v)
{
cerr << "[ ";
for (T i : v)
{
_print(i);
cerr << " ";
}
cerr << "]";
}

template <class T>
void _print(vector<vector<T>> v)
{
cerr << "[\n";
for (int l = 0; l < v.size(); l++)
{
{
for (int k = 0; k < v[l].size(); k++)
cerr << v[l][k] << " ";
}
cerr << "\n";
}
cerr << "]";
}

template <class T, class V>
void _print(map<T, V> v)
{
cerr << "[ ";
for (auto i : v)
{
_print(i);
cerr << " ";
}
cerr << "]";
}

template <class T>
void _print(set<T> v)
{
cerr << "[ ";
for (T i : v)
{
_print(i);
cerr << " ";
}
cerr << "]";
}

const long long inf = 1e18;
const int MOD = 1e9 + 7;
const int MAX = 1e6;

bool isValid(string s)
{
int len = s.size();
for (int i = 0; i < len / 2; i++)
{
if (s[i] != s[len - 1 - i])
return false;
}
return true;
}

void rotateMatrix(vector<vector<int>> &v, int n)
{
for (int i = 0; i < n / 2; i++)
{
for (int j = i; j < n - i - 1; j++)
{
int ptr = v[i][j];
v[i][j] = v[n - 1 - j][i];
v[n - 1 - j][i] = v[n - 1 - i][n - 1 - j];
v[n - 1 - i][n - 1 - j] = v[j][n - 1 - i];
v[j][n - 1 - i] = ptr;
}
}
}

vector<bool> is_prime(10001, 1);
vector<int> primes;

void seive()
{
is_prime[0] = 0;
is_prime[1] = 0;
for (int i = 2; i < 10001; i++)
{
if (is_prime[i])
{
primes.push_back(i);
for (int j = i + i; j < 10001; j += i)
{
is_prime[j] = 0;
}
}
}
}

bool ispal(int ind,int ind2,string s,int dp[],int n){
while(ind2>=ind){
if(s[ind]==s[ind2]){
ind++;ind2--;
}
else
return 0;
}
return 1;
}

int rec(int ind,string s,int dp[],int n) {
if(ind==n)
return 1;
if(dp[ind]!=-1)
return dp[ind];
int ans=0;
for(int i=ind;i<n;i++){
if(ispal(ind,i,s,dp,n)){
ans=(ans+rec(i+1,s,dp,n))%1000000007;
}
}
return dp[ind]=ans;
}

int32_t main() {

ll t; cin >> t;
// seive();
while (t--) {

ll l,r;cin>>l>>r;

cout<< 1002583<<endl;

}
return 0;
}

``````

## Coprime Range CodeChef Solution in PYTH 3

``````
from sys import stdin, stdout

stdout.write('{}\n'.format(1000003))``````

## Coprime Range CodeChef Solution in C

``````#include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int i,k;
scanf("%d%d",&i,&k);
printf("1299827\n");
}
}``````

## Coprime Range CodeChef Solution in JAVA

``````/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{

StringTokenizer st;

{
}

String next()
{
while (st == null || !st.hasMoreElements()) {
try {
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}

int nextInt() { return Integer.parseInt(next()); }

long nextLong() { return Long.parseLong(next()); }

double nextDouble()
{
return Double.parseDouble(next());
}

String nextLine()
{
String str = "";
try {
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
static boolean prime[]= new boolean[10000001];
public static void  sieve()
{

for(int i=0;i<=10000000;i++)
prime[i] = true;
prime[0] = prime[1] = false;
for(int p = 2; p*p <=10000000; p++)
{
// If prime[p] is not changed, then it is a prime
if(prime[p] == true)
{
// Update all multiples of p
for(int i = p*p; i <= 10000000; i += p)
prime[i] = false;
}
}

}
static ArrayList<Integer> primeFactors(int n)
{
ArrayList<Integer> pflist=new ArrayList<>();
int c = 2;
while (n > 1) {
if (n % c == 0) {
n /= c;
}
else
c++;
}
return pflist;
}

public static void main (String[] args) throws java.lang.Exception
{
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));

int cases = sc.nextInt();
//sieve();
while(cases-->0)
{
int x=sc.nextInt();
int y=sc.nextInt();
out.write(1000003+"\n");
}
out.flush();
}
public static void reverse(int[] array)
{
int n=array.length;
for(int i=0;i<n/2;i++)
{
int temp=array[i];
array[i]=array[n-i-1];
array[n-i-1]=temp;
}
}
public static String dectobin32(int x)
{
StringBuilder result = new StringBuilder();

for (int i = 31; i >= 0 ; i--)
{
int mask = 1 << i;
result.append((x & mask) != 0 ? 1 : 0);
}
//Integer.parseInt(result,2)
return result.toString();
}

}
class Pair implements Comparable<Pair> {
int first,second;

public Pair(int first,int second)
{
this.first =first;
this.second=second;
}
public int compareTo(Pair b)
{
//first element in descending order
if (this.first!=b.first)
return (this.first>b.first)?-1:1;
else
return this.second<b.second?-1:1;
//second element in incresing order
}
}``````

## Coprime Range CodeChef Solution in PYPY 3

``````for _ in range(int(input())):
l,r = map(int,input().split())
print(1000003)``````

## Coprime Range CodeChef Solution in PYTH

``````t = int(raw_input())
for i in range(t):
st = raw_input().split()
L = int(st[0])
R = int(st[1])
P = 1000003
print P
# endfor i
``````

## Coprime Range CodeChef Solution in C#

``````using System;
using System.Collections.Generic;

public class Test
{
private static void Fill(IList<long> list, ref string str)
{
checked
{
list.Clear();
var strIdx = 0;
var sign = 1;
var curr = 0;

while (strIdx < str.Length)
{
if (str[strIdx] == ' ')
{
curr = 0;
sign = 1;
}
else if (str[strIdx] == '-')
{
sign = -1;
curr = 0;
}
else
{
curr *= 10;
curr += str[strIdx] - '0';
}

strIdx++;
}

}
}

{
}

{
}

public static void Main()
{
checked
{
List<long> lr = new List<long>(2);

for (int i = 0; i < tests; i++)
{
Fill(lr, ref str);
Console.WriteLine(1000000007);
}
}
}
}``````

## Coprime Range CodeChef Solution in GO

``````package main

import (
"bufio"
"bytes"
"fmt"
"os"
)

func main() {

var buf bytes.Buffer

for tc > 0 {
tc--
res := solve(l, r)
buf.WriteString(fmt.Sprintf("%d\n", res))
}

fmt.Print(buf.String())
}

func readInt(bytes []byte, from int, val *int) int {
i := from
sign := 1
if bytes[i] == '-' {
sign = -1
i++
}
tmp := 0
for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
tmp = tmp*10 + int(bytes[i]-'0')
i++
}
*val = tmp * sign
return i
}

return
}

a, b = res[0], res[1]
return
}

a, b, c = res[0], res[1], res[2]
return
}

res := make([]int, n)
x := 0
for i := 0; i < n; i++ {
for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
x++
}
}
return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
i := from

var tmp uint64
for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
tmp = tmp*10 + uint64(bytes[i]-'0')
i++
}
*val = tmp

return i
}

func solve(l, r int) int {
return 1000000007
}``````
##### Coprime Range CodeChef Solution Review:

In our experience, we suggest you solve this Coprime Range CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Coprime Range CodeChef Solution.

Find on CodeChef

##### Conclusion:

I hope this Coprime Range CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Programming Language in a business context; there are no prerequisites.

Keep Learning!