This commit is contained in:
AB
2020-07-08 05:31:09 +03:00
parent 1dcd90ab28
commit 8bb620d289
9 changed files with 30 additions and 5 deletions

0
.a.out.c Normal file
View File

BIN
a.out

Binary file not shown.

BIN
counter Executable file

Binary file not shown.

View File

@ -2,7 +2,7 @@
Dim last As Long
Dim As Long num, digit, sum, start, end_
start = 0
end_ = 1000000
end_ = 1000000000
repeat:
If start < end_ Then

21
som.js Normal file
View File

@ -0,0 +1,21 @@
console.time('st')
const getNumSum = (num) => {
let buf = num
let res = 0;
while (buf > 0) {
res = res + buf % 10
buf = Math.floor(buf / 10)
}
return res
}
const end = 1000000000
let result = 0
for(let i = 1; i <= end; i++){
result += getNumSum(i)
}
console.log(result)
console.timeEnd('st')

BIN
sum Executable file

Binary file not shown.

4
sum.c
View File

@ -35,8 +35,8 @@ int main(int argc, char *argv[])
{
long end, start, first, last, shift, i, temp;
int p_pid = getpid();
long f_count = 3 * get_nprocs_conf();
// long f_count = 1;
// long f_count = 3 * get_nprocs_conf();
long f_count = 1;
pid_t pid;
main_result = mmap(NULL, sizeof *main_result,
PROT_READ | PROT_WRITE,

5
sum.go
View File

@ -26,11 +26,12 @@ func sum_chunk(first int, last int, channel chan int) {
func main() {
// need to change it to getting from args
var first, last int = 0, 1000000000
//var first, last int = 0, 1000000000
var first, last int = 0, 1000000000000
//fmt.Scanln(&first, "enter first value")
//fmt.Scanln(&last, "enter last value")
fmt.Println("Processing sequence from", first, "to", last)
nprocs := runtime.NumCPU()
nprocs := runtime.NumCPU() * 3
//nprocs = 1
runtime.GOMAXPROCS(nprocs)
if last <= nprocs {

3
sum.v Normal file
View File

@ -0,0 +1,3 @@
fn main() {
println('Hello, developers!')
}