Skip to content

Instantly share code, notes, and snippets.

@Bunyod
Last active May 24, 2019 23:49
Show Gist options
  • Save Bunyod/8c0c2389825adc581e44714c8735c722 to your computer and use it in GitHub Desktop.
Save Bunyod/8c0c2389825adc581e44714c8735c722 to your computer and use it in GitHub Desktop.
Print a document as a book
package utils
/**
* @author Bunyod Bobojonov ([email protected]). Created at 6/1/16.
*/
object Pagination {
def main(args: Array[String]): Unit = {
println("Hello World from main function!")
var evens = ""
var odds = ""
val n = 100 // number of pages
val m = n/2
for (i <- 1 to m+1) {
if (i%2 == 0) {
evens = evens + s"$i,${2*(m-i) + (i+1)},"
} else {
odds = odds + s"${2*(m-i) + (i+1)},$i,"
}
}
println(evens)
println("-----------------------")
println(odds)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment