Skip to content

Instantly share code, notes, and snippets.

@shigemk2
Created Apr 17, 2015
Embed
What would you like to do?
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