28 lines
599 B
Plaintext
28 lines
599 B
Plaintext
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);
|
|
}
|
|
}
|