# Sum multiples of 3 and 5

```ruby
func sumMul(n, f) {
    var m = int((n - 1) / f)
    f * m * (m + 1) / 2
}

func sum35(n) {
    sumMul(n, 3) + sumMul(n, 5) - sumMul(n, 15)
}

for i in (1..20) {
    printf("%2s:%22s %s\n", i, 10**i, sum35(10**i))
}
```

#### Output:

```
 1:                    10 23
 2:                   100 2318
 3:                  1000 233168
 4:                 10000 23331668
 5:                100000 2333316668
 6:               1000000 233333166668
 7:              10000000 23333331666668
 8:             100000000 2333333316666668
 9:            1000000000 233333333166666668
10:           10000000000 23333333331666666668
11:          100000000000 2333333333316666666668
12:         1000000000000 233333333333166666666668
13:        10000000000000 23333333333331666666666668
14:       100000000000000 2333333333333316666666666668
15:      1000000000000000 233333333333333166666666666668
16:     10000000000000000 23333333333333331666666666666668
17:    100000000000000000 2333333333333333316666666666666668
18:   1000000000000000000 233333333333333333166666666666666668
19:  10000000000000000000 23333333333333333331666666666666666668
20: 100000000000000000000 2333333333333333333316666666666666666668
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://trizen.gitbook.io/sidef-lang/programming_tasks/s/sum_multiples_of_3_and_5.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
