Eban numbers: Difference between revisions

Python example
m (→‎{{header|Perl 6}}: Update for module change)
(Python example)
Line 698:
count_eban(10^21) : 1,279,999,999
"0.0s"
</pre>
=={{header|Python}}==
<lang Python>
# Use inflect
 
"""
 
show all eban numbers <= 1,000 (in a horizontal format), and a count
show all eban numbers between 1,000 and 4,000 (inclusive), and a count
show a count of all eban numbers up and including 10,000
show a count of all eban numbers up and including 100,000
show a count of all eban numbers up and including 1,000,000
show a count of all eban numbers up and including 10,000,000
"""
 
import inflect
import time
 
before = time.perf_counter()
 
p = inflect.engine()
 
# eban numbers <= 1000
 
print(' ')
print('eban numbers up to and including 1000:')
print(' ')
 
count = 0
 
for i in range(1,1001):
if not 'e' in p.number_to_words(i):
print(str(i)+' ',end='')
count += 1
print(' ')
print(' ')
print('count = '+str(count))
print(' ')
 
# eban numbers 1000 to 4000
 
print(' ')
print('eban numbers between 1000 and 4000 (inclusive):')
print(' ')
 
count = 0
 
for i in range(1000,4001):
if not 'e' in p.number_to_words(i):
print(str(i)+' ',end='')
count += 1
print(' ')
print(' ')
print('count = '+str(count))
print(' ')
 
# eban numbers up to 10000
 
print(' ')
print('eban numbers up to and including 10000:')
print(' ')
 
count = 0
 
for i in range(1,10001):
if not 'e' in p.number_to_words(i):
count += 1
print(' ')
print('count = '+str(count))
print(' ')
 
# eban numbers up to 100000
 
print(' ')
print('eban numbers up to and including 100000:')
print(' ')
 
count = 0
 
for i in range(1,100001):
if not 'e' in p.number_to_words(i):
count += 1
print(' ')
print('count = '+str(count))
print(' ')
 
# eban numbers up to 1000000
 
print(' ')
print('eban numbers up to and including 1000000:')
print(' ')
 
count = 0
 
for i in range(1,1000001):
if not 'e' in p.number_to_words(i):
count += 1
print(' ')
print('count = '+str(count))
print(' ')
 
# eban numbers up to 10000000
 
print(' ')
print('eban numbers up to and including 10000000:')
print(' ')
 
count = 0
 
for i in range(1,10000001):
if not 'e' in p.number_to_words(i):
count += 1
print(' ')
print('count = '+str(count))
print(' ')
 
after = time.perf_counter()
 
print(" ")
print("Run time in seconds: "+str(after - before))
</lang>
 
Output:
<pre>
eban numbers up to and including 1000:
2 4 6 30 32 34 36 40 42 44 46 50 52 54 56 60 62 64 66
count = 19
eban numbers between 1000 and 4000 (inclusive):
2000 2002 2004 2006 2030 2032 2034 2036 2040 2042 2044 2046 2050 2052 2054 2056 2060 2062 2064 2066 4000
count = 21
eban numbers up to and including 10000:
count = 79
eban numbers up to and including 100000:
count = 399
eban numbers up to and including 1000000:
count = 399
eban numbers up to and including 10000000:
count = 1599
Run time in seconds: 1134.289519125
</pre>