Vampire number: Difference between revisions

Added Easylang
m (→‎{{header|RPL}}: tweaked the code)
(Added Easylang)
Line 1,037:
24959017348650 = 2947050 x 8469153 = 2949705 x 8461530 = 4125870 x 6049395 = 4129587 x 6043950 = 4230765 x 5899410
14593825548650 is not vampiric</pre>
 
=={{header|EasyLang}}==
{{trans|C}}
<syntaxhighlight>
func dtally x .
while x > 0
t += bitshift 1 (x mod 10 * 6)
x = x div 10
.
return t
.
proc fangs x . f[] .
f[] = [ ]
nd = floor log10 x + 1
if nd mod 2 = 1
return
.
nd = nd div 2
lo = higher pow 10 (nd - 1) (x + pow 10 nd - 2) div (pow 10 nd - 1)
hi = lower (x / lo) sqrt x
t = dtally x
for a = lo to hi
b = x div a
if a * b = x and (a mod 10 > 0 or b mod 10 > 0) and t = dtally a + dtally b
f[] &= a
.
.
.
proc show_fangs x f[] . .
write x & " "
for f in f[]
write " = " & f & " x " & x div f
.
print ""
.
x = 1
while n < 25
fangs x f[]
if len f[] > 0
n += 1
write n & ": "
show_fangs x f[]
.
x += 1
.
bigs[] = [ 16758243290880 24959017348650 14593825548650 ]
for x in bigs[]
fangs x f[]
if len f[] > 0
show_fangs x f[]
else
print x & " is not vampiric"
.
.
</syntaxhighlight>
 
=={{header|Eiffel}}==
2,078

edits