Created
August 27, 2022 18:49
-
-
Save MinekPo1/6dc43816644463e1342b619b4deca3aa to your computer and use it in GitHub Desktop.
SCPP benchmark (primes)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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