mirror of
https://github.com/house-of-vanity/sum_counter.git
synced 2025-07-06 05:04:07 +00:00
some
This commit is contained in:
@ -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
21
som.js
Normal 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')
|
4
sum.c
4
sum.c
@ -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
5
sum.go
@ -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 {
|
||||
|
Reference in New Issue
Block a user