Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,38 @@
// Version 1.2.70
import kotlin.math.abs
infix fun Int.pow(e: Int): Int {
if (e == 0) return 1
var prod = this
for (i in 2..e) {
prod *= this
}
return prod
}
fun main(args: Array<String>) {
var prod = 1
var sum = 0
val x = 5
val y = -5
val z = -2
val one = 1
val three = 3
val seven = 7
val p = 11 pow x
fun process(j: Int) {
sum += abs(j)
if (abs(prod) < (1 shl 27) && j != 0) prod *= j
}
for (j in -three..(3 pow 3) step three) process(j)
for (j in -seven..seven step x) process(j)
for (j in 555..550-y) process(j)
for (j in 22 downTo -28 step three) process(j)
for (j in 1927..1939) process(j)
for (j in x downTo y step -z) process(j)
for (j in p..p + one) process(j)
System.out.printf("sum = % ,d\n", sum)
System.out.printf("prod = % ,d\n", prod)
}

View file

@ -0,0 +1,31 @@
import kotlin.math.abs
import kotlin.math.pow
private infix fun Int.`^`(exponent: Int): Int = toDouble().pow(exponent).toInt()
fun main() {
var prod = 1
var sum = 0
val x = 5
val y = -5
val z = -2
val one = 1
val three = 3
val seven = 7
val p = 11 `^` x
for (j in sequenceOf(
-three..(3 `^` 3) step three,
-seven..seven step x,
555..550-y,
22 downTo -28 step three,
1927..1939,
x downTo y step -z,
p..p + one
).flatten()) {
sum += abs(j)
if (abs(prod) < (2 `^` 27) && j != 0) prod *= j
}
System.out.printf("sum = % ,d\n", sum)
System.out.printf("prod = % ,d\n", prod)
}