Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Vampire Numbers

by Abigail-II (Bishop)
on Jun 11, 2002 at 12:53 UTC ( #173452=note: print w/ replies, xml ) Need Help??


in reply to Vampire Numbers

Here's a piece of code that finds all Vampire numbers with factors smaller than the argument given:

#!/usr/bin/perl use strict; use warnings 'all'; my @vampire; foreach my $s (1 .. shift) { LOOP: foreach my $t (1 .. $s) { my $prod = $s * $t; my $cat = "$s$t"; foreach my $d (0 .. 9) { next LOOP unless eval "\$prod =~ y/$d/$d/ == \$cat =~ y/$d/$d/"; } push @vampire => [$prod, $s, $t]; } } @vampire = sort {$a -> [0] <=> $b -> [0]} @vampire; foreach my $vamp (@vampire) { printf "%4d * %4d = %8d\n" => @$vamp [1, 2, 0]; }

Note that if there is one vampire number (and there is), then we have an infinite number of vampire numbers. Proof: Suppose V = n * m is a vampire number. Then 10 * V = (10 * n) * m is a vampire number as well. qed.

Abigail

Here are the vampire numbers with factors smaller than 100:
  21 *    6 =      126
  51 *    3 =      153
  86 *    8 =      688
  60 *   21 =     1260
  93 *   15 =     1395
  41 *   35 =     1435
  51 *   30 =     1530
  87 *   21 =     1827
  81 *   27 =     2187
  86 *   80 =     6880


Comment on Re: Vampire Numbers
Download Code
Re: Re: Formulas for certain 'fangs'
by Anonymous Monk on Jun 11, 2002 at 17:26 UTC
    a couple of general formulas such as the the fangs

    x = 25.10^k+1 y = 100(10^(k+1)+52)/25

    give the vampire

    v = xy = (10^(k+1)+52)10^(k+2)+100(10^k+1+52)/25 = x'.10^(k+2)+t
    = 8(26+5.10^k)(1+25.10^k)

    where x' denotes x with digits reversed

      153 is also a plus perfect number or 'armstrong' number

      153=1^3+5^3+3^3=1+125+27

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://173452]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (16)
As of 2014-07-11 15:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (230 votes), past polls