# Scriptorium

## VBA : Project Euler: Project Euler - Problem #1

### Details:

 Type: sub Added By: Rembo Short Description: ```From their website: "What is Project Euler? Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems. The motivation for starting Project Euler, and its continuation, is to provide a platform for the inquiring mind to delve into unfamiliar areas and learn new concepts in a fun and recreational context." After reading some of the solutions discussed in Dick's blog I thought it would be fun to post some solutions on this website as well. Rather than copying and pasting solutions of other people I will post my own solution. They may not be the most efficient solutions but they do the job. The challenge is of course to find your own solution, although the use of the internet is encouraged. Please see the Project Euler website for a full explanation. If you find this challenging I encourage you to sign up (free) and see how far you get with programming your VBA solution. ``` Notes: `The problem description is included with the code.` Added: Jan 31 2009 at 1:44 PM Modified: Feb 5 2009 at 11:59 AM Related URLs `http://www.dailydoseofexcel.com/` `http://projecteuler.net`

### Usage:

`Run the routine, the answer is printed in the debugging screen.`

### Code:

`'Euler 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.  Sub Euler_0001()    Dim i As Long    Dim iTotal As Long     iTotal = 0    For i = 1 To Int(999.99 / 3)        iTotal = iTotal + (i * 3)    Next i    For i = 1 To Int(999.99 / 5)        iTotal = iTotal + (i * 5)    Next i    For i = 1 To Int(999.99 / 15)        iTotal = iTotal - (i * 15)    Next i    Debug.Print iTotalEnd Sub `