Chuyen de So Nguyen To
Chuyen de So Nguyen To
h>
#include <bits/stdc++.h>
using namespace std;
int a[10000000];
void sang(){
for(int i=0;i<=10000000;i++){
a[i]=1;
}
a[0]=a[1]=0;
for(int i=2;i<=sqrt(10000000);i++){
if(a[i]){
for(int j=i*i;j<=10000000;j+=i){
a[j]=0;
}
}
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
sang();
for(int i=1;i<n;i++){
if(a[i]){
cout<<i<<" ";
}
}
}
#include <bits/stdc++.h>
using namespace std;
long long n;
int a[10000000];
void sang(){
for(int i=2;i*i<=n;i++)
{
int mu=0;
while(n%i==0)
{
mu++;
n/=i;
}
if(mu>0) cout<<i<<" ^ "<<mu;
cout<<" * ";
}
if(n>1) cout<<n<<" ^ "<<1;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>n;
sang();
}
#include <bits/stdc++.h>
int main()
{ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
bool x=1;
cin>>n;
while(n>0){
for(int i=2;i<=sqrt(n);i++){
if(n%i==0){
x=0;
}
}
if(n<2){
x=0;
}
if(x==0){
cout<<"FALSE";
break;
}
n/=10;
}
if(x==1){
cout<<"TRUE";
}
return 0;
}
#include <bits/stdc++.h>
void sang()
for(int i=2;i<=10000000;i++)
{
a[i]=1;
for(int i=1;i*i<=10000000;i++)
if(a[i])
for(int j=i*i;j<=10000000;j+=i)
a[j]=0;
int main()
long long n;
cin>>n;
sang();
for(int i=2;i<=n;i++)
if(a[i])
for(int j=2;j<=n;j++)
if(pow(2,j)-1==i)
cout<<i<<" ";
#include <bits/stdc++.h>
using namespace std;
bool kt(int n) {
if (n < 2) return false;
for (int i = 2; i * i <= n; ++i) {
if (n % i == 0) return false;
}
return true;
}
int main() {
int n;
cin>>n;
bool lc=true;
for (int i = 2; i < n; ++i)
if (kt(i)==1&&kt(i+2)==1)
{
if(!lc) cout<<",";
cout<<"("<<i<<","<<i+2<<")";
lc=false;
}
#include <bits/stdc++.h>
using namespace std;
int a[1000000];
int n,i=2,dem=0;
bool snt(int n) {
if (n < 2) return false;
for (int i = 2; i * i <= n; ++i) {
if (n % i == 0) return false;
}
return true;
}
int stt(int n) {
int dem = 0, so = 2;
while (true) {
if (snt(so)) {
++dem;
if (dem == n) return so;
}
++so;
}
}
int main() {
cin>>n;
while(dem<=n)
{
int x=1;
for (int j = 2; j * j <= i; ++j)
if (i % j == 0) x=0;
if(x==1)
{
dem++;
a[dem]=i;
}
i++;
}
cout<<a[n];
}
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
long long n,a[10000000];
void sang()
{
for(int i=2;i<=10000000;i++)
{
a[i]=1;
}
for(int i=1;i*i<=10000000;i++)
if(a[i])
for(int j=i*i;j<=10000000;j+=i)
{
a[j]=0;
}
}
bool ktdx(int n) {
int nguyenban = n;
int sodx = 0;
while (n > 0) {
int m = n % 10;
sodx = sodx * 10 + m;
n /= 10;
}
return nguyenban == sodx;
}
int main()
{
cin>>n;
sang();
bool lc=true;
for(int i=2;i<=n;i++)
{
if(a[i])
{
if(ktdx(i))
{
if(!lc) cout<<",";
cout<<i;
lc=false;
}
}
}
}
#include <bits/stdc++.h>
}
}
*giải thích:
#include <bits/stdc++.h>
void sang()
int main()
cin>>p;
sang();
if(m<10000000&&a[m]) cout<<"TRUE";
else cout<<"FALSE";