0% found this document useful (0 votes)
25 views2 pages

Coding

The document contains C++ code for functions to check if a number is prime, a power of two, and for modular inverse. It also contains a Sieve of Eratosthenes function to find all primes below a given limit. The main function takes in a string, reverses it and prints the original and reversed string.

Uploaded by

Simran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views2 pages

Coding

The document contains C++ code for functions to check if a number is prime, a power of two, and for modular inverse. It also contains a Sieve of Eratosthenes function to find all primes below a given limit. The main function takes in a string, reverses it and prints the original and reversed string.

Uploaded by

Simran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include<bits/stdc++.

h>
#define ll long long int
#define nl '\n'
#define vi vector<ll>
#define pb push_back
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pi 3.141592653589793238462643383279502884197169399
const ll mod = 1e9+7;
using namespace std;
bool prime(ll n)
{

if (n <= 1) return false;


if (n <= 3) return true;

if (n%2 == 0 || n%3 == 0) return false;

for (ll i=5; i*i<=n; i=i+6)


if (n%i == 0 || n%(i+2) == 0)
return false;

return true;
}
bool isPowerOfTwo(ll n)
{
if(n==0)
return false;

return (ceil(log2(n)) == floor(log2(n)));


}
void SieveOfEratosthenes(ll n)
{

bool prime[n+1];
memset(prime, true, sizeof(prime));

for (ll p=2; p*p<=n; p++)


{

if (prime[p] == true)
{

for (ll i=p*p; i<=n; i += p)


prime[i] = false;
}
}

for (ll p=2; p<=n; p++)


if (prime[p])
cout << p << " ";
}
ll modularinv(ll x,ll n)
{
if(n==0)
return 1;
else if(n%2==0)
return modularinv((x*x)%mod,n/2);
else
return (x*modularinv((x*x)%mod,(n-1)/2))%mod;

int main()
{
io;
ll t,i,l,r,m,n,j;
//cin>>t;
t=1;
while(t--)
{
string s;
cin>>s;
cout<<s;
reverse(all(s));
cout<<s;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy