> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/v/vampire_number.md).

# Vampire number

```ruby
func is_vampire (n) {
    return [] if n.ilog10.is_even

    var l1 = n.isqrt.ilog10.ipow10
    var l2 = n.isqrt

    var s = n.digits.sort.join

    gather {
        n.divisors.each { |d|

            d < l1 && next
            d > l2 && break

            var t = n/d

            next if (d%%10 && t%%10)
            next if ("#{d}#{t}".sort != s)

            take([d, t])
        }
    }
}

say "First 25 Vampire Numbers:"

with (1) { |i|
    for (var n = 1; i <= 25; ++n) {
        var fangs = is_vampire(n)
        printf("%2d. %6s : %s\n", i++, n, fangs.join(' ')) if fangs
    }
}

say "\nIndividual tests:"

[16758243290880, 24959017348650, 14593825548650].each { |n|
    var fangs = is_vampire(n)
    say "#{n}: #{fangs ? fangs.join(', ') : 'is not a vampire number'}"
}
```

## Output:

```
First 25 Vampire Numbers:
 1.   1260 : [21, 60]
 2.   1395 : [15, 93]
 3.   1435 : [35, 41]
 4.   1530 : [30, 51]
 5.   1827 : [21, 87]
 6.   2187 : [27, 81]
 7.   6880 : [80, 86]
 8. 102510 : [201, 510]
 9. 104260 : [260, 401]
10. 105210 : [210, 501]
11. 105264 : [204, 516]
12. 105750 : [150, 705]
13. 108135 : [135, 801]
14. 110758 : [158, 701]
15. 115672 : [152, 761]
16. 116725 : [161, 725]
17. 117067 : [167, 701]
18. 118440 : [141, 840]
19. 120600 : [201, 600]
20. 123354 : [231, 534]
21. 124483 : [281, 443]
22. 125248 : [152, 824]
23. 125433 : [231, 543]
24. 125460 : [204, 615] [246, 510]
25. 125500 : [251, 500]

Individual tests:
16758243290880: [1982736, 8452080], [2123856, 7890480], [2751840, 6089832], [2817360, 5948208]
24959017348650: [2947050, 8469153], [2949705, 8461530], [4125870, 6049395], [4129587, 6043950], [4230765, 5899410]
14593825548650: is not a vampire number
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://trizen.gitbook.io/sidef-lang/programming_tasks/v/vampire_number.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
