** solution for problems 1**

=============================================================

Problem 1
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.

Find the sum of all the multiples of 3 or 5 below 1000.

**----------------------------------------**

#include<iostream.h>

int main()

{

int sum=0;

for (int i=1; i<1000 ; i++)

{

if((i%3==0) || (i%5==0))

{

sum+=i;

}

}

cout<<"sum is "<<sum<<endl;

return 1;

}

Answer : 233168

---------- Post added at 04:13 AM ---------- Previous post was at 04:06 AM ----------

** solution for problems 2**

=============================================================
**Problem 2**
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

Find the sum of all the even-valued terms in the sequence which do not exceed four million.

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

#include<iostream.h>

int main()

{

int f0=1,f1=2,f2,sum=0;

while( (f2=f0+f1) < 4000000)

{

if(f1%2==0)sum+=f1;

f0=f1;

f1=f2;

}

cout<<"Sum is "<<sum<<endl;

return 1;

}

**Answer: 1089154**

---------- Post added at 04:31 AM ---------- Previous post was at 04:13 AM ----------

**solution for problems 4**

=============================================================

**Problem 4**
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91

99.

Find the largest palindrome made from the product of two 3-digit numbers.

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

#include<iostream.h>

int rev(int num){

int r=0;

while(num)

{

r=r*10+num%10;

num=num/10;

}

return r;

}

int main()

{

int n;

int max=0,i_k=0,j_k=0;

for(int i=999; i>100; i--)

for(int j=999;j >100; j--)

{

n=i*j;

if(n<=max)

{

break;

}

if(n ==rev(n))

{

// cout<<"n is "<<n<<endl;

if(n>=max)

{

max=n;

i_k=i;

j_k=j;

}

}

}

cout<<i_k<<" *"<<j_k<<"= "<<max;

return 1;

}

**Answer : 993*913 = 906609**

---------- Post added at 04:36 AM ---------- Previous post was at 04:31 AM ----------

**solution for problems 5**

=============================================================

**Problem 5**

2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.

What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?

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

#include<iostream.h>

int find_lcm(int x,int y)

{

int a,lcm;

if(y>x){

a=x;

x=y;

y=a;

}

/*x is the larges number;*/

lcm=x;

while(lcm%y != 0)

{

lcm+=x;

}

return lcm;

}

int main()

{

int lcm=1,t,quit=0;

for(int i=2;i<=20 ; i++)

{

//find LCM

lcm=find_lcm(lcm,i);

}

cout<<"Ans : "<< lcm<<endl;

return 1;

}

**Answer : 232792560**