first prime numbers less than
C++
#include<bits/stdc++.h>
using namespace std;
bool Is_Prime(long long x){
if(x%2==0)return false;
for(int i=3;i*i<=x;i+=2)
if(x%i==0)return false;
return true;
}
int main(){
//primes less than n
int n;
cin>>n;
int primes=0,i=1;
while(primes++<n){
while(!Is_Prime(++i));
cout<<i<<" ";
}
}
Also in C++:
- Title
- fmod c++
- Category
- C++
- Title
- power c++
- Category
- C++
- Title
- c++ string to vector int
- Category
- C++
- Title
- how to pushback in vector
- Category
- C++
- Title
- std::reverse
- Category
- C++
- Title
- rick astley - never gonna give you up
- Category
- C++
- Title
- char* to int in cpp
- Category
- C++
- Title
- bool function in c++
- Category
- C++
- Title
- pop_back
- Category
- C++
- Title
- getline not working c++
- Category
- C++
- Title
- traverse map c++
- Category
- C++
- Title
- user input c++
- Category
- C++
- Title
- C++ Student::Student()
- Category
- C++
- Title
- Temporary file using MSFT API in cpp
- Category
- C++
- Title
- pyqt connect
- Category
- C++
- Title
- how to sort an array according to another array c++
- Category
- C++
- Title
- git branch in my bash prompt
- Category
- C++
- Title
- create a dictionary cpp
- Category
- C++
- Title
- c++ convert int to double
- Category
- C++
- Title
- what is sigsegv error in c++
- Category
- C++
- Title
- substitution failure is not an error
- Category
- C++
- Title
- c++ isalphanum
- Category
- C++
- Title
- number of islands leetcode code
- Category
- C++
- Title
- heap in cpp stl
- Category
- C++
- Title
- pop from between string c++
- Category
- C++
- Title
- object reference not set to an instance of an object c#
- Category
- C++
- Title
- findung the mode in c++
- Category
- C++
- Title
- c++ files
- Category
- C++
- Title
- c++ read matttrix from text file
- Category
- C++
- Title
- c++ replace substrings
- Category
- C++
- Title
- c++ unittest in ros
- Category
- C++
- Title
- type id c++
- Category
- C++
- Title
- Merge k sorted linked lists and return it as one sorted list.
- Category
- C++
- Title
- binary representation differ in bits
- Category
- C++
- Title
- multiset c++
- Category
- C++
- Title
- counting valleys hackerrank solution in c++
- Category
- C++
- Title
- factorion
- Category
- C++
- Title
- stringstream in c++
- Category
- C++
- Title
- Read multiple files(.txt) c++
- Category
- C++
- Title
- how to open an input file in c++
- Category
- C++
- Title
- c++ get type name of object
- Category
- C++
- Title
- how long can a c++ string be
- Category
- C++
- Title
- c++ clamp
- Category
- C++
- Title
- delete 2d dynamic array c++
- Category
- C++
- Title
- c++ random numbers
- Category
- C++
- Title
- rosrun actionlib_msgs genaction.py
- Category
- C++
- Title
- c++ clear stream
- Category
- C++
- Title
- c++ string^ to char*
- Category
- C++
- Title
- C++ If
- Category
- C++
- Title
- prims c++
- Category
- C++
- Title
- compare values within within a vector c++
- Category
- C++
- Title
- c++ clear console
- Category
- C++
- Title
- how to grab all of user input c++
- Category
- C++
- Title
- calculate factorial
- Category
- C++
- Title
- c++ remove element from vector
- Category
- C++
- Title
- for loop
- Category
- C++
- Title
- C++ user input
- Category
- C++
- Title
- convert stirng to int c++
- Category
- C++
- Title
- variabvles in c++
- Category
- C++
- Title
- c++ stack
- Category
- C++
- Title
- c++ multiple inheritance diamond problem
- Category
- C++
- Title
- c++ write string
- Category
- C++
- Title
- root to leaf path print
- Category
- C++
- Title
- class in c++
- Category
- C++
- Title
- variabili in c++
- Category
- C++
- Title
- maximum subarray sum in c++
- Category
- C++
- Title
- nginx linux
- Category
- C++
- Title
- how to print a string to console in c++
- Category
- C++
- Title
- power in c++
- Category
- C++
- Title
- min coin change problem dp
- Category
- C++
- Title
- getline in c++
- Category
- C++
- Title
- how to run c++ file mingw cmd
- Category
- C++
- Title
- double pointers C++
- Category
- C++
- Title
- is not a nonstatic data member or base class of class
- Category
- C++
- Title
- memset
- Category
- C++
- Title
- how to create object in c++
- Category
- C++
- Title
- mkdir c++
- Category
- C++
- Title
- % operator in c++
- Category
- C++
- Title
- new in c++
- Category
- C++
- Title
- 1d fixed length arrays c++
- Category
- C++
- Title
- c++ delet from memory
- Category
- C++
- Title
- first fit algorithm
- Category
- C++
- Title
- c++ switch case statement
- Category
- C++
- Title
- string substr c++
- Category
- C++
- Title
- c++ switch
- Category
- C++
- Title
- how to declare a vector in c++
- Category
- C++
- Title
- hohw toparse a string in c++
- Category
- C++
- Title
- set c++
- Category
- C++
- Title
- c++ char define
- Category
- C++
- Title
- file objects in c++
- Category
- C++
- Title
- double ended queue in c++ stl
- Category
- C++
- Title
- how to append one vector to another c++
- Category
- C++
- Title
- is TLE means my code is correct but taking more time to computr
- Category
- C++
- Title
- new c++
- Category
- C++
- Title
- ceil c++;
- Category
- C++
- Title
- how to ensure the user inouts a int and not anything else c++
- Category
- C++
- Title
- can we compare a long long int with int in c++ using max or min functions
- Category
- C++
- Title
- C++ and endl
- Category
- C++
- Title
- friend function in c++
- Category
- C++
- Title
- statement that causes a function to end in c++
- Category
- C++