feature: calculating if a number is a prime

still not there yet, haven't figured out the functional programming
style of scala + have to find a way to make calculating primes a bit
heavier on the ALU, and stress the branch predictor aswell. Still
figuring stuff out.
This commit is contained in:
Abdellah El Morabit 2025-11-16 22:24:52 +01:00
parent e4e3a567ab
commit a66ec9fb87

View File

@ -1,5 +1,46 @@
package com.nsrddyn package com.nsrddyn
class Prime {
class Prime(threads: Int) {
/*
* Calculate all primes up to limit
* This should stress the ALU in someway,
* doing this in a predictable manner,
* will hopefully keep the cpu pipeline busy
* and that way stress the branch predictor
*
* */
// TODO: bad implementation of scala, scala prefers functional programming which something I am not doing here
def run(n: Long): Unit = {
var iterator = 0
// TODO: run the isPrime checks
}
def isPrime(n: Int): Boolean = {
for
i <- 2 to 5
if isWholeNumber(n % i) == true then
true
false
// TODO: calculate if the number is a prime number
// TODO: fix errors
}
def isWholeNumber(n: Int | Float): Boolean = {
// TODO: calculate if the number is a whole number
}
} }