# Project Euler Question

• 04-25-2009
Project Euler Question
Im doing problem five on Project Euler. Basically, your supposed to find the smallest number that is evenly divided by the numbers from 1-20. heres my code, its just outputting 21, the condition on my loop.
Code:

```#include <iostream> using namespace std; bool Divisible(int num, int divisor); int main() {         int end;         int i = 3;         int I = 2;         while (!Divisible(i,I))         {                 i++;                 I = 2;                 do                 {                         Divisible(i, I);                         if (!Divisible)                                 I = 21;                         else                                 I++;                 }while(I <= 20);                         end = i;         }         cout<<end; } bool Divisible(int num,int divisor) {         if (num % divisor == 0)                 return true;         else                 return false; }```
• 04-25-2009
cyberfish
A number divisible by 1-20 WILL be much greater than 20.
• 04-25-2009
cyberfish
Your code doesn't make much sense either... review your C++. Especially the section on functions.
• 04-26-2009
to the first commenter, im aware of that, thats the problem. and to the second person, it makes sense to me, could you refrence something specifically.
• 04-26-2009
cyberfish
They are the same person btw, as am I :).

Quote:

could you refrence something specifically
Quote:

Code:

`if (!Divisible)`

A function call must have brackets, with the right number of arguments.

What you are doing now is taking the address of the function, and evaluate that, which is most likely going to evaluate to true all the time, since it's probably not 0.

Sidenote:
Quote:

Code:

```bool Divisible(int num,int divisor) {         if (num % divisor == 0)                 return true;         else                 return false; }```

is more conventionally written
Code:

```bool Divisible(int num,int divisor) {         return num % divisor == 0; }```
• 04-26-2009