Skip to content

Instantly share code, notes, and snippets.

@MinekPo1
Created August 27, 2022 18:49
Show Gist options
  • Save MinekPo1/6dc43816644463e1342b619b4deca3aa to your computer and use it in GitHub Desktop.
Save MinekPo1/6dc43816644463e1342b619b4deca3aa to your computer and use it in GitHub Desktop.
SCPP benchmark (primes)
#include <math>
#include <time>
namespace benchmark {
func is_prime(num){
for(i from 2 to math::floor(math::sqrt(num),0) + 1){
if((num % i) == 0) {
return 0;
}
}
return 1;
}
public func main() {
var i = 3;
var c = 1;
println("2");
while (c < 1000){
if (is_prime(i)){
println(i);
c = c + 1;
}
i = i + 1;
}
var t = time::getRuntimeMillis();
print("done in ");
print(t/1000);
print("s");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment