Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created April 17, 2015 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shigemk2/a024b5e532de58d5b0e0 to your computer and use it in GitHub Desktop.
Save shigemk2/a024b5e532de58d5b0e0 to your computer and use it in GitHub Desktop.
void function(int n) {
int i, j, k , count = 0;
for(i = n/2; i <= n; i++) {
for(j = 1; j + n/2 <= n; j = j + 1) {
for(k = 1; k <= n; k = k * 2) {
count++;
printf("i: %d, j: %d, k: %d, count: %d\n", i, j, k, count);
}
}
}
}
main() {
function(8);
}
object one25 {
def Function(n: Int): Unit = {
var count: Int = 0
for(i <- n/2 to n; j <- 1 to n if j + n/2 <= n; k <- Iterator.iterate(1)(_ * 2) takeWhile (_ <= n)) {
count = count + 1
printf("i: %d, j: %d, k: %d, count: %d\n", i, j, k, count)
}
}
def main(args: Array[String]) {
Function(8);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment