Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
27
Task/Fusc-sequence/Processing/fusc-sequence.processing
Normal file
27
Task/Fusc-sequence/Processing/fusc-sequence.processing
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
void setup() {
|
||||
println("First 61 terms:");
|
||||
for (int i = 0; i < 60; i++) {
|
||||
print(fusc(i) + " ");
|
||||
}
|
||||
println(fusc(60));
|
||||
println();
|
||||
println("Sequence elements where number of digits of the value increase:");
|
||||
int max_len = 0;
|
||||
for (int i = 0; i < 700000; i++) {
|
||||
int temp = fusc(i);
|
||||
if (str(temp).length() > max_len) {
|
||||
max_len = str(temp).length();
|
||||
println("(" + i + ", " + temp + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int fusc(int n) {
|
||||
if (n <= 1) {
|
||||
return n;
|
||||
} else if (n % 2 == 0) {
|
||||
return fusc(n / 2);
|
||||
} else {
|
||||
return fusc((n - 1) / 2) + fusc((n + 1) / 2);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue