Data update
This commit is contained in:
parent
0df55f9f24
commit
aec8ed51b6
1045 changed files with 18889 additions and 2777 deletions
14
Task/Tau-function/Asymptote/tau-function.asymptote
Normal file
14
Task/Tau-function/Asymptote/tau-function.asymptote
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
write("The tau functions for the first 100 positive integers are:");
|
||||
for (int N = 1; N <= 100; ++N) {
|
||||
int T;
|
||||
if (N < 3) {
|
||||
T = N;
|
||||
} else {
|
||||
T = 2;
|
||||
for (int A = 2; A <= (N + 1) / 2; ++A) {
|
||||
if (N % A == 0) T = T + 1;
|
||||
}
|
||||
}
|
||||
write(format("%3d", T), suffix=none);
|
||||
if (N % 10 == 0) write("");
|
||||
}
|
||||
22
Task/Tau-function/Dart/tau-function.dart
Normal file
22
Task/Tau-function/Dart/tau-function.dart
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
int divisorCount(int n) {
|
||||
int total = 1;
|
||||
// Deal with powers of 2 first
|
||||
for (; (n & 1) == 0; n >>= 1) total++;
|
||||
// Odd prime factors up to the square root
|
||||
for (int p = 3; p * p <= n; p += 2) {
|
||||
int count = 1;
|
||||
for (; n % p == 0; n ~/= p) count++;
|
||||
total *= count;
|
||||
}
|
||||
// If n > 1 then it's prime
|
||||
if (n > 1) total *= 2;
|
||||
return total;
|
||||
}
|
||||
|
||||
void main() {
|
||||
const int limit = 100;
|
||||
print("Count of divisors for the first $limit positive integers:");
|
||||
for (int n = 1; n <= limit; ++n) {
|
||||
print(divisorCount(n).toString().padLeft(3));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue