langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
|
|
@ -0,0 +1,35 @@
|
|||
# This very limited BCD-based collection of functions
|
||||
# makes it easy to count very large numbers. All arrays
|
||||
# start off with the ones columns in position zero.
|
||||
# Using arrays of decimal-based digits to model integers
|
||||
# doesn't make much sense for most tasks, but if you
|
||||
# want to keep counting forever, this does the trick.
|
||||
|
||||
BcdInteger =
|
||||
from_string: (s) ->
|
||||
arr = []
|
||||
for c in s
|
||||
arr.unshift parseInt(c)
|
||||
arr
|
||||
|
||||
render: (arr) ->
|
||||
s = ''
|
||||
for elem in arr
|
||||
s = elem.toString() + s
|
||||
s
|
||||
|
||||
succ: (arr) ->
|
||||
arr = (elem for elem in arr)
|
||||
i = 0
|
||||
while arr[i] == 9
|
||||
arr[i] = 0
|
||||
i += 1
|
||||
arr[i] ||= 0
|
||||
arr[i] += 1
|
||||
arr
|
||||
|
||||
# To start counting from 1, change the next line!
|
||||
big_int = BcdInteger.from_string "199999999999999999999999999999999999999999999999999999"
|
||||
while true
|
||||
console.log BcdInteger.render big_int
|
||||
big_int = BcdInteger.succ big_int
|
||||
Loading…
Add table
Add a link
Reference in a new issue