Update appNew update is available. Click here to update.
About
A team builder having a drive for knowledge and crave for creative things. To achieve success in a competitive environment and with a blend of my hard work and passion, I strive to leave a lasting imp...
BML Munjal University 2024
C++ - Default language
My Stats
EXP gained
yellow-spark
7010
Level
6 (Specialist)
Community stats
Discussions
0
Upvotes
0
Know more
203
Total problems solved
184
Easy
18
Moderate
1
Hard
0
Ninja
Jan Jan Feb Feb Mar Mar Apr Apr May May Jun Jun Jul Jul Aug Aug Sep Sep Oct Oct Nov Nov Dec Dec

Current streak:

0 days

Longest streak:

12 days

Less

More

Achievements
3
Ronin
Topics
Arrays
Stacks & Queues
Sorting
1
Sensei
Guided path
Pointers
Discussions
C++ Solution
Interview problems

int main() {

    int n, i, j, flag = 0;

    cin>>n;

    for (i = 2; i <= n; i++) {

        flag = 0;

        for (j = 2; j <= sqrt(i); j++) {

            if (i % j == 0) {

                flag = 1; 

                break;

            }

        }

        if (flag == 0)

            cout<<i<<endl;

    }

 

    return 0;

}

profile
Sujit78
Published On 05-Aug-2023
46 views
0 replies
0 upvotes