Category talk:Wren-i64: Difference between revisions

(→‎Source code (Wren): Added largestPrime and prev{rime)
 
(2 intermediate revisions by the same user not shown)
Line 28:
 
==Source code (Wren)==
<syntaxhighlight lang="ecmascriptwren">/* Module "i64.wren" */
 
import "./trait" for Comparable
Line 360:
copy() { I64.from(this) } // copies 'this' to a new I64 object
 
isOdd { this % I64.two =!= I64.onezero } // true if 'this' is odd
isEven { this % I64.two == I64.zero } // true if 'this' is even
isZero { this == I64.zero } // true if 'this' is zero
Line 1,112:
return 0
}
// Return a list of the current instance's base 10 digits
digits { toString.map { |d| Num.fromString(d) }.toList }
 
digits { toString.map { |d| Num.fromString(d) }.toList } // aReturns listthe sum of the current instance's base 10 digits.
digitSum {
digitSum { digits.reduce(0) { |acc, d| acc = acc + d } } // the sum of those digits
var sum = 0
for (d in toString.bytes) sum = sum + d - 48
return sum
}
}
 
9,476

edits