ps6: init
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
func main() {
|
||||
println("First printing every power of two less than 1000")
|
||||
|
||||
var i = 1
|
||||
while (i < 1000) {
|
||||
println("i is now ", i)
|
||||
i = i*2
|
||||
}
|
||||
|
||||
println("")
|
||||
println("Now printing every product with factors less than 6")
|
||||
|
||||
i = 1
|
||||
while (i < 6) {
|
||||
var j
|
||||
j = 1
|
||||
while (j < i) {
|
||||
println(j, " * ", i, " = ", i*j)
|
||||
j = j+1
|
||||
}
|
||||
i = i+1
|
||||
}
|
||||
}
|
||||
|
||||
//TESTCASE:
|
||||
//First printing every power of two less than 1000
|
||||
//i is now 1
|
||||
//i is now 2
|
||||
//i is now 4
|
||||
//i is now 8
|
||||
//i is now 16
|
||||
//i is now 32
|
||||
//i is now 64
|
||||
//i is now 128
|
||||
//i is now 256
|
||||
//i is now 512
|
||||
//
|
||||
//Now printing every product with factors less than 6
|
||||
//1 * 2 = 2
|
||||
//1 * 3 = 3
|
||||
//2 * 3 = 6
|
||||
//1 * 4 = 4
|
||||
//2 * 4 = 8
|
||||
//3 * 4 = 12
|
||||
//1 * 5 = 5
|
||||
//2 * 5 = 10
|
||||
//3 * 5 = 15
|
||||
//4 * 5 = 20
|
||||
Reference in New Issue
Block a user