Printing prime numbers from 1 through 100

前端 未结 22 2447
无人共我
无人共我 2020-11-28 05:14

This c++ code prints out the following prime numbers: 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97.

But I don\'t think tha

22条回答
  •  自闭症患者
    2020-11-28 05:51

    This is my very simple c++ program to list down the prime numbers in between 2 and 100.

    for(int j=2;j<=100;++j)
    {
        int i=2;
        for(;i<=j-1;i++)
        {
            if(j%i == 0)
                break;
        }
    
        if(i==j && i != 2)
            cout<

提交回复
热议问题