Category talk:Wren-long: Difference between revisions
Content added Content deleted
(→Source code: Added some properties to Longs and ULongs classes for dealing with ranges.) |
(→Source code: Added 'digits' and 'digitSum' methods to ULong class.) |
||
Line 949: | Line 949: | ||
..(n) { ULongs.range(this, n, 1, true) } // inclusive of 'n' |
..(n) { ULongs.range(this, n, 1, true) } // inclusive of 'n' |
||
...(n) { ULongs.range(this, n, 1, false) } // exclusive of 'n' |
...(n) { ULongs.range(this, n, 1, false) } // exclusive of 'n' |
||
// Return a list of the current instance's base 10 digits |
|||
digits { toString.map { |d| Num.fromString(d) }.toList } |
|||
// Returns the sum of the current instance's base 10 digits. |
|||
digitSum { |
|||
var sum = 0 |
|||
for (d in toString.bytes) sum = sum + d - 48 |
|||
return sum |
|||
} |
|||
/* Prime factorization methods. */ |
/* Prime factorization methods. */ |