If my interpretation is right, following should be the code.

int main()
{
int userInteger = 0;
cout << "Enter A Number "<<endl;
cin >> userInteger; // Ask For a number from the user
if (userInteger > 0) // Is the number valid?
{
int result = 0;
int prime[5] = { 2, 3, 5, 7, 11 };
int a,b, count = 0;
*for(a=1;a<=userInteger;++a) // Looping to user's input
{
  for(b=0;b < 5;++b) // Looping the prime numbers array
   {
   if (a % prime[b] == 0) //if divisible by any number, just end it there
   break;
  }
 //break or end of loop will bring the control here
 if(b==5) //a was not divisible by any of the first 5 prime numbers
 {
 result+=a;
 ++count;
 }
}*
cout << "Numbers Not evenly divisible by 5 prime numbers: " << count
<< endl;
cout << "The Sum of numbers not evenly divisible by 5 prime numbers: "
<< result << endl;
}
getch();
return 0;
}

--------------------------------------------------------------------------------------------------------------------------------

As per my solution,
Test Cases:
1)
userInteger = 20
count = 4
Numbers will be: 1, 13, 17, 19
result = 50

2)
userInteger = 35
count = 7
Numbers will be: 1, 13, 17, 19, 23, 29, 31
result = 133




Even numbers can never be there in this list as they are all divisible by 2.
Bfore 169, only prime numbers can be included.
Hope my interpretation of your question was correct

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to