This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env kscript | |
var factor = 2 | |
fun doubleIt(n: Int) = n * factor | |
var message = "The factor is $factor" | |
factor = 0 | |
println(doubleIt(2)) | |
println(message) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package dev.hbrown | |
/** | |
* Demonstrates the importance of limiting the scope of a variable using the Sieve of Eratosthenes to find prime numbers | |
* using a sequence builder. The algorithm is conceptually very easy: | |
* | |
* 1. take a list of numbers starting at 2. | |
* 2. remove the first number, it is prime. | |
* 3. from the rest of the numbers, remove the first number as well as all the numbers divisible by this prime number. | |
* |
OlderNewer