September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,16 +1,16 @@
|
|||
func sdn(n) {
|
||||
var b = [0]*n.len;
|
||||
var a = n.chars;
|
||||
func sdn(Number n) {
|
||||
var b = [0]*n.len
|
||||
var a = n.digits
|
||||
a.each { |i| b[i] := 0 ++ }
|
||||
a.join == b.join;
|
||||
a == b
|
||||
}
|
||||
|
||||
var values = <1210 2020 21200 3211000
|
||||
42101000 521001000 6210001000 27 115508>;
|
||||
var values = [1210, 2020, 21200, 3211000,
|
||||
42101000, 521001000, 6210001000, 27, 115508]
|
||||
|
||||
values.each { |test|
|
||||
say "#{test} is #{sdn(test) ? '' : 'NOT ' }a self describing number.";
|
||||
say "#{test} is #{sdn(test) ? '' : 'NOT ' }a self describing number."
|
||||
}
|
||||
|
||||
say "\nSelf-descriptive numbers less than 1e5 (in base 10):"
|
||||
0.to(1e5).each { |i| say i if sdn(i.to_s) }
|
||||
^1e5 -> each { |i| say i if sdn(i) }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
7.to(36).each { |b|
|
||||
var n = ((b-4) * b**(b-1) + 2*(b**(b-2)) + b**(b-3) + b**3 -> base(b));
|
||||
say "base #{'%2d' % b}: #{n}";
|
||||
for b in (7 .. 36) {
|
||||
var n = ((b-4) * b**(b-1) + 2*(b**(b-2)) + b**(b-3) + b**3 -> base(b))
|
||||
say "base #{'%2d' % b}: #{n}"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue