Shnap, (削除) 44 (削除ここまで) 43 bytes
-1 bye thanks to Mr. Xcoder (lol I was outgolfed in my own language)
$n return:{s=0for d:range(n+1)if n%d<1s+=d}
This is a function ($ starts a function in Shnap).
Explanation:
$ n //Start function with parameter n
return: { //Technically, we are returning a scope-block, which evaluates to the last statement run
s = 0 //Our result
for d : range(n+1) //For each value in the iterator range(n+1)
if n % d < 1 // If n is divisible by d
s += d // Add d to the sum
// Since (s += d) returns (s + d), and a scope-block returns the last run statement, this will be the last statement and equal to our result
}
Noncompeting, 19 bytes
#Noncompeting, 19 bytes AfterAfter many language updates, this can now be reduced to a measly 19 bytes:
$n=>sum(factors(n))
Shnap, (削除) 44 (削除ここまで) 43 bytes
-1 bye thanks to Mr. Xcoder (lol I was outgolfed in my own language)
$n return:{s=0for d:range(n+1)if n%d<1s+=d}
This is a function ($ starts a function in Shnap).
Explanation:
$ n //Start function with parameter n
return: { //Technically, we are returning a scope-block, which evaluates to the last statement run
s = 0 //Our result
for d : range(n+1) //For each value in the iterator range(n+1)
if n % d < 1 // If n is divisible by d
s += d // Add d to the sum
// Since (s += d) returns (s + d), and a scope-block returns the last run statement, this will be the last statement and equal to our result
}
#Noncompeting, 19 bytes After many language updates, this can now be reduced to a measly 19 bytes:
$n=>sum(factors(n))
Shnap, (削除) 44 (削除ここまで) 43 bytes
-1 bye thanks to Mr. Xcoder (lol I was outgolfed in my own language)
$n return:{s=0for d:range(n+1)if n%d<1s+=d}
This is a function ($ starts a function in Shnap).
Explanation:
$ n //Start function with parameter n
return: { //Technically, we are returning a scope-block, which evaluates to the last statement run
s = 0 //Our result
for d : range(n+1) //For each value in the iterator range(n+1)
if n % d < 1 // If n is divisible by d
s += d // Add d to the sum
// Since (s += d) returns (s + d), and a scope-block returns the last run statement, this will be the last statement and equal to our result
}
Noncompeting, 19 bytes
After many language updates, this can now be reduced to a measly 19 bytes:
$n=>sum(factors(n))
Shnap, (削除) 44 (削除ここまで) 43 bytes
-1 bye thanks to Mr. Xcoder (lol I was outgolfed in my own language)
$n return:{s=0for d:range(n+1)if n%d<1s+=d}
This is a function ($ starts a function in Shnap).
Explanation:
$ n //Start function with parameter n
return: { //Technically, we are returning a scope-block, which evaluates to the last statement run
s = 0 //Our result
for d : range(n+1) //For each value in the iterator range(n+1)
if n % d < 1 // If n is divisible by d
s += d // Add d to the sum
// Since (s += d) returns (s + d), and a scope-block returns the last run statement, this will be the last statement and equal to our result
}
#Noncompeting, 19 bytes After many language updates, this can now be reduced to a measly 19 bytes:
$n=>sum(factors(n))
Shnap, (削除) 44 (削除ここまで) 43 bytes
-1 bye thanks to Mr. Xcoder (lol I was outgolfed in my own language)
$n return:{s=0for d:range(n+1)if n%d<1s+=d}
This is a function ($ starts a function in Shnap).
Explanation:
$ n //Start function with parameter n
return: { //Technically, we are returning a scope-block, which evaluates to the last statement run
s = 0 //Our result
for d : range(n+1) //For each value in the iterator range(n+1)
if n % d < 1 // If n is divisible by d
s += d // Add d to the sum
// Since (s += d) returns (s + d), and a scope-block returns the last run statement, this will be the last statement and equal to our result
}
Shnap, (削除) 44 (削除ここまで) 43 bytes
-1 bye thanks to Mr. Xcoder (lol I was outgolfed in my own language)
$n return:{s=0for d:range(n+1)if n%d<1s+=d}
This is a function ($ starts a function in Shnap).
Explanation:
$ n //Start function with parameter n
return: { //Technically, we are returning a scope-block, which evaluates to the last statement run
s = 0 //Our result
for d : range(n+1) //For each value in the iterator range(n+1)
if n % d < 1 // If n is divisible by d
s += d // Add d to the sum
// Since (s += d) returns (s + d), and a scope-block returns the last run statement, this will be the last statement and equal to our result
}
#Noncompeting, 19 bytes After many language updates, this can now be reduced to a measly 19 bytes:
$n=>sum(factors(n))
Shnap, 44(削除) 44 (削除ここまで) 43 bytes
-1 bye thanks to Mr. Xcoder (lol I was outgolfed in my own language)
$n return:{s=0for d:range(n+1)if n%d==0s+=dn%d<1s+=d}
This is a function ($ starts a function in Shnap).
Explanation:
$ n //Start function with parameter n
return: { //Technically, we are returning a scope-block, which evaluates to the last statement run
s = 0 //Our result
for d : range(n+1) //For each value in the iterator range(n+1)
if n % d ==< 01 // If n is divisible by d
s += d // Add d to the sum
// Since (s += d) returns (s + d), and a scope-block returns the last run statement, this will be the last statement and equal to our result
}
Shnap, 44 bytes
$n return:{s=0for d:range(n+1)if n%d==0s+=d}
This is a function ($ starts a function in Shnap).
Explanation:
$ n //Start function with parameter n
return: { //Technically, we are returning a scope-block, which evaluates to the last statement run
s = 0 //Our result
for d : range(n+1) //For each value in the iterator range(n+1)
if n % d == 0 // If n is divisible by d
s += d // Add d to the sum
// Since (s += d) returns (s + d), and a scope-block returns the last run statement, this will be the last statement and equal to our result
}
Shnap, (削除) 44 (削除ここまで) 43 bytes
-1 bye thanks to Mr. Xcoder (lol I was outgolfed in my own language)
$n return:{s=0for d:range(n+1)if n%d<1s+=d}
This is a function ($ starts a function in Shnap).
Explanation:
$ n //Start function with parameter n
return: { //Technically, we are returning a scope-block, which evaluates to the last statement run
s = 0 //Our result
for d : range(n+1) //For each value in the iterator range(n+1)
if n % d < 1 // If n is divisible by d
s += d // Add d to the sum
// Since (s += d) returns (s + d), and a scope-block returns the last run statement, this will be the last statement and equal to our result
}