Submission
Status:
PPPPPP-PP-
Subtask/Task Score:
80/100
Score: 80
User: KanemiyaKana
Problemset: จำนวนเฉพาะ (2560)
Language: cpp
Time: 0.002 second
Submitted On: 2026-09-22 15:23:51
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
void primecheck(int number)
{
for (int i = 2; i <= number; i++)
{
bool prime = true;
int multiple = floor(sqrt(i));
int j = 2;
while (j <= multiple) // check from 2 to the square root of the number to see if it is prime
{
if (i % j == 0) // if the number(i) is divisible by j
{
prime = false;
break; // break out of the loop if a divisor is found i dont even get what the hell im typing
}
j++;
}
if (prime)
{
cout << i << endl;
}
}
}
int main()
{
int input;
cin >> input;
if (1 > input || input > 100)
{
return 0;
}
primecheck(input);
}