import java.time.Duration
import java.time.LocalDateTime
import kotlin.math.sqrt

class Term(var coeff: Long, var ix1: Byte, var ix2: Byte)

const val maxDigits = 16

fun toLong(digits: List<Byte>, reverse: Boolean): Long {
    var sum: Long = 0
    if (reverse) {
        var i = digits.size - 1
        while (i >= 0) {
            sum = sum * 10 + digits[i]
            i--
        }
    } else {
        var i = 0
        while (i < digits.size) {
            sum = sum * 10 + digits[i]
            i++
        }
    }
    return sum
}

fun isSquare(n: Long): Boolean {
    val root = sqrt(n.toDouble()).toLong()
    return root * root == n
}

fun seq(from: Byte, to: Byte, step: Byte): List<Byte> {
    val res = mutableListOf<Byte>()
    var i = from
    while (i <= to) {
        res.add(i)
        i = (i + step).toByte()
    }
    return res
}

fun commatize(n: Long): String {
    var s = n.toString()
    val le = s.length
    var i = le - 3
    while (i >= 1) {
        s = s.slice(0 until i) + "," + s.substring(i)
        i -= 3
    }
    return s
}

fun main() {
    val startTime = LocalDateTime.now()
    var pow = 1L
    println("Aggregate timings to process all numbers up to:")