Skip to content

Instantly share code, notes, and snippets.

@xenowits
Last active August 4, 2022 07:44
Show Gist options
  • Save xenowits/502566a1ac2b778b9afae04aa068282a to your computer and use it in GitHub Desktop.
Save xenowits/502566a1ac2b778b9afae04aa068282a to your computer and use it in GitHub Desktop.
// [rust] run with `rustc main.rs && ./main`
fn main() {
for n in 4..20 {
let t = (2*n) as f64 / 3 as f64;
println!("{} of {}", t.ceil(), n);
}
}
// [javascript] run with `node main.js`
const fn = () => {
for (let n = 4; n < 20; n++) {
let t = parseInt(Math.ceil((2 * n) / 3));
console.log(t, "of", n);
}
};
fn();
// [go] run with `go run main.go`
package main
import (
"fmt"
"math"
)
func main() {
for n := 4; n < 20; n++ {
fmt.Println(int(math.Ceil(float64(2*n)/3)), "of", n)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment