Quick actions

cmd+k|ctrl+k

Navigation

Languages

lab6-54

Snippet info

Language

Cpp

Visibility

public

Author

matho.camara

Created

2018-11-28T06:56:52Z

Updated

2018-11-28T07:02:56Z

#include <iostream>
using namespace std;

int main() {
    int tSize,f,counter=0;
    int *Table;
    cout << "Input a number :"<<endl;
    cin>>tSize;
    bool oddNumber=false;
    
    Table=new int[tSize];
    
    //computing
    cout<<"Odd numbers smaller than "<<tSize<<":"<<endl;
    for(int i=tSize-1;i>1;i--)
    {
       f=i-1;
        for(int j=f;j>1;j--)
         {
             if(i%j!=0)
             oddNumber=true;
             else
             {
                 oddNumber=false;
                 break;
             }
         }
         if(oddNumber==true)
         {
             Table[counter]=i;
             counter++;
         }
    }
    //table element
    cout<<counter<<" element(s) found :"<<endl;
    for(int i=0;i<tSize;i++)
    {
        if(Table[i]!=0)
        cout<<Table[i]<<endl;
    }
    return 0;
}
INFO