Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Sandbox

Post History

50%
+0 −0
#5: Post edited by user avatar trichoplax‭ · 2024-02-19T15:06:51Z (9 months ago)
Add finalized to title
  • Fibonacci numbers with no consecutive digits
  • Fibonacci numbers with no consecutive digits [FINALIZED]
#4: Post edited by user avatar trichoplax‭ · 2024-02-19T15:05:34Z (9 months ago)
Mark as finalized
  • Output the Nth number in the list of [Fibonacci numbers](https://en.wikipedia.org/wiki/Fibonacci_sequence) that have no consecutive digits.
  • ## Input
  • - A non-negative integer.
  • ## Output
  • - The Nth number in the list of Fibonacci numbers whose base 10 (decimal) representation has no adjacent digits that are consecutive.
  • - The Fibonacci numbers start with 0 and 1, then each subsequent Fibonacci number is the sum of the previous two Fibonacci numbers.
  • - The Fibonacci numbers are zero indexed:
  • - For input 0, the output is 0.
  • - For input 1, the output is 1.
  • - Two digits are consecutive if their absolute difference is 1.
  • - The consecutive digits can be in either ascending or descending order - either will lead to exclusion from the list.
  • ## Examples
  • ### Single digit Fibonacci numbers
  • - A single digit number has no adjacent digits, so all single digit Fibonacci numbers are included.
  • ### Two digit Fibonacci numbers
  • - 34 and 89 are excluded because their digits are consecutive.
  • - 21 is also excluded due to consecutive digits in descending order.
  • ### Non-adjacent consecutive digits
  • - 46368 contains the digits 4 and 3, which are consecutive digits. However, they are not adjacent (being separated by a 6) so 46368 is included.
  • ## Test cases
  • Test cases are in the format `input : output`.
  • ```text
  • 0 : 0
  • 1 : 1
  • 2 : 1
  • 3 : 2
  • 4 : 3
  • 5 : 5
  • 6 : 8
  • 7 : 13
  • 8 : 55
  • 9 : 144
  • 10 : 377
  • 11 : 1597
  • 12 : 2584
  • 13 : 4181
  • 14 : 17711
  • 15 : 46368
  • 16 : 75025
  • 17 : 196418
  • 18 : 514229
  • 19 : 14930352
  • 20 : 39088169
  • ```
  • ## Scoring
  • This is a [code golf challenge]. Your score is the number of bytes in your code. Lowest score for each language wins.
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • [code golf challenge]: https://codegolf.codidact.com/categories/49/tags/4274 "The code-golf tag"
  • # Now posted: [Fibonacci without consecutive digits](https://codegolf.codidact.com/posts/290870)
  • ---
  • Output the Nth number in the list of [Fibonacci numbers](https://en.wikipedia.org/wiki/Fibonacci_sequence) that have no consecutive digits.
  • ## Input
  • - A non-negative integer.
  • ## Output
  • - The Nth number in the list of Fibonacci numbers whose base 10 (decimal) representation has no adjacent digits that are consecutive.
  • - The Fibonacci numbers start with 0 and 1, then each subsequent Fibonacci number is the sum of the previous two Fibonacci numbers.
  • - The Fibonacci numbers are zero indexed:
  • - For input 0, the output is 0.
  • - For input 1, the output is 1.
  • - Two digits are consecutive if their absolute difference is 1.
  • - The consecutive digits can be in either ascending or descending order - either will lead to exclusion from the list.
  • ## Examples
  • ### Single digit Fibonacci numbers
  • - A single digit number has no adjacent digits, so all single digit Fibonacci numbers are included.
  • ### Two digit Fibonacci numbers
  • - 34 and 89 are excluded because their digits are consecutive.
  • - 21 is also excluded due to consecutive digits in descending order.
  • ### Non-adjacent consecutive digits
  • - 46368 contains the digits 4 and 3, which are consecutive digits. However, they are not adjacent (being separated by a 6) so 46368 is included.
  • ## Test cases
  • Test cases are in the format `input : output`.
  • ```text
  • 0 : 0
  • 1 : 1
  • 2 : 1
  • 3 : 2
  • 4 : 3
  • 5 : 5
  • 6 : 8
  • 7 : 13
  • 8 : 55
  • 9 : 144
  • 10 : 377
  • 11 : 1597
  • 12 : 2584
  • 13 : 4181
  • 14 : 17711
  • 15 : 46368
  • 16 : 75025
  • 17 : 196418
  • 18 : 514229
  • 19 : 14930352
  • 20 : 39088169
  • ```
  • ## Scoring
  • This is a [code golf challenge]. Your score is the number of bytes in your code. Lowest score for each language wins.
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • [code golf challenge]: https://codegolf.codidact.com/categories/49/tags/4274 "The code-golf tag"
#3: Post edited by user avatar trichoplax‭ · 2024-02-19T00:02:33Z (9 months ago)
Specify zero indexed and add an example
  • Output the Nth number in the list of [Fibonacci numbers](https://en.wikipedia.org/wiki/Fibonacci_sequence) that have no consecutive digits.
  • ## Input
  • - A non-negative integer.
  • ## Output
  • - The Nth number in the list of Fibonacci numbers whose base 10 (decimal) representation has no adjacent digits that are consecutive.
  • - The Fibonacci numbers start with 0 and 1, then each subsequent Fibonacci number is the sum of the previous two Fibonacci numbers.
  • - Two digits are consecutive if their absolute difference is 1.
  • - The consecutive digits can be in either ascending or descending order - either will lead to exclusion from the list.
  • ## Examples
  • ### Single digit Fibonacci numbers
  • - A single digit number has no adjacent digits, so all single digit Fibonacci numbers are included.
  • ### Two digit Fibonacci numbers
  • - 34 and 89 are excluded because their digits are consecutive.
  • - 21 is also excluded due to consecutive digits in descending order.
  • ## Test cases
  • Test cases are in the format `input : output`.
  • ```text
  • 0 : 0
  • 1 : 1
  • 2 : 1
  • 3 : 2
  • 4 : 3
  • 5 : 5
  • 6 : 8
  • 7 : 13
  • 8 : 55
  • 9 : 144
  • 10 : 377
  • 11 : 1597
  • 12 : 2584
  • 13 : 4181
  • 14 : 17711
  • 15 : 46368
  • 16 : 75025
  • 17 : 196418
  • 18 : 514229
  • 19 : 14930352
  • 20 : 39088169
  • ```
  • ## Scoring
  • This is a [code golf challenge]. Your score is the number of bytes in your code. Lowest score for each language wins.
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • [code golf challenge]: https://codegolf.codidact.com/categories/49/tags/4274 "The code-golf tag"
  • Output the Nth number in the list of [Fibonacci numbers](https://en.wikipedia.org/wiki/Fibonacci_sequence) that have no consecutive digits.
  • ## Input
  • - A non-negative integer.
  • ## Output
  • - The Nth number in the list of Fibonacci numbers whose base 10 (decimal) representation has no adjacent digits that are consecutive.
  • - The Fibonacci numbers start with 0 and 1, then each subsequent Fibonacci number is the sum of the previous two Fibonacci numbers.
  • - The Fibonacci numbers are zero indexed:
  • - For input 0, the output is 0.
  • - For input 1, the output is 1.
  • - Two digits are consecutive if their absolute difference is 1.
  • - The consecutive digits can be in either ascending or descending order - either will lead to exclusion from the list.
  • ## Examples
  • ### Single digit Fibonacci numbers
  • - A single digit number has no adjacent digits, so all single digit Fibonacci numbers are included.
  • ### Two digit Fibonacci numbers
  • - 34 and 89 are excluded because their digits are consecutive.
  • - 21 is also excluded due to consecutive digits in descending order.
  • ### Non-adjacent consecutive digits
  • - 46368 contains the digits 4 and 3, which are consecutive digits. However, they are not adjacent (being separated by a 6) so 46368 is included.
  • ## Test cases
  • Test cases are in the format `input : output`.
  • ```text
  • 0 : 0
  • 1 : 1
  • 2 : 1
  • 3 : 2
  • 4 : 3
  • 5 : 5
  • 6 : 8
  • 7 : 13
  • 8 : 55
  • 9 : 144
  • 10 : 377
  • 11 : 1597
  • 12 : 2584
  • 13 : 4181
  • 14 : 17711
  • 15 : 46368
  • 16 : 75025
  • 17 : 196418
  • 18 : 514229
  • 19 : 14930352
  • 20 : 39088169
  • ```
  • ## Scoring
  • This is a [code golf challenge]. Your score is the number of bytes in your code. Lowest score for each language wins.
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • [code golf challenge]: https://codegolf.codidact.com/categories/49/tags/4274 "The code-golf tag"
#2: Post edited by user avatar trichoplax‭ · 2024-02-17T23:08:06Z (9 months ago)
Add link and explanation of Fibonacci numbers
  • Output the Nth number in the list of Fibonacci numbers that have no consecutive digits.
  • ## Input
  • - A non-negative integer.
  • ## Output
  • - The Nth number in the list of Fibonacci numbers whose base 10 (decimal) representation has no adjacent digits that are consecutive.
  • - Two digits are consecutive if their absolute difference is 1.
  • - The consecutive digits can be in either ascending or descending order - either will lead to exclusion from the list.
  • ## Examples
  • ### Single digit Fibonacci numbers
  • - A single digit number has no adjacent digits, so all single digit Fibonacci numbers are included.
  • ### Two digit Fibonacci numbers
  • - 34 and 89 are excluded because their digits are consecutive.
  • - 21 is also excluded due to consecutive digits in descending order.
  • ## Test cases
  • Test cases are in the format `input : output`.
  • ```text
  • 0 : 0
  • 1 : 1
  • 2 : 1
  • 3 : 2
  • 4 : 3
  • 5 : 5
  • 6 : 8
  • 7 : 13
  • 8 : 55
  • 9 : 144
  • 10 : 377
  • 11 : 1597
  • 12 : 2584
  • 13 : 4181
  • 14 : 17711
  • 15 : 46368
  • 16 : 75025
  • 17 : 196418
  • 18 : 514229
  • 19 : 14930352
  • 20 : 39088169
  • ```
  • ## Scoring
  • This is a [code golf challenge]. Your score is the number of bytes in your code. Lowest score for each language wins.
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • [code golf challenge]: https://codegolf.codidact.com/categories/49/tags/4274 "The code-golf tag"
  • Output the Nth number in the list of [Fibonacci numbers](https://en.wikipedia.org/wiki/Fibonacci_sequence) that have no consecutive digits.
  • ## Input
  • - A non-negative integer.
  • ## Output
  • - The Nth number in the list of Fibonacci numbers whose base 10 (decimal) representation has no adjacent digits that are consecutive.
  • - The Fibonacci numbers start with 0 and 1, then each subsequent Fibonacci number is the sum of the previous two Fibonacci numbers.
  • - Two digits are consecutive if their absolute difference is 1.
  • - The consecutive digits can be in either ascending or descending order - either will lead to exclusion from the list.
  • ## Examples
  • ### Single digit Fibonacci numbers
  • - A single digit number has no adjacent digits, so all single digit Fibonacci numbers are included.
  • ### Two digit Fibonacci numbers
  • - 34 and 89 are excluded because their digits are consecutive.
  • - 21 is also excluded due to consecutive digits in descending order.
  • ## Test cases
  • Test cases are in the format `input : output`.
  • ```text
  • 0 : 0
  • 1 : 1
  • 2 : 1
  • 3 : 2
  • 4 : 3
  • 5 : 5
  • 6 : 8
  • 7 : 13
  • 8 : 55
  • 9 : 144
  • 10 : 377
  • 11 : 1597
  • 12 : 2584
  • 13 : 4181
  • 14 : 17711
  • 15 : 46368
  • 16 : 75025
  • 17 : 196418
  • 18 : 514229
  • 19 : 14930352
  • 20 : 39088169
  • ```
  • ## Scoring
  • This is a [code golf challenge]. Your score is the number of bytes in your code. Lowest score for each language wins.
  • > Explanations are optional, but I'm more likely to upvote answers that have one.
  • [code golf challenge]: https://codegolf.codidact.com/categories/49/tags/4274 "The code-golf tag"
#1: Initial revision by user avatar trichoplax‭ · 2024-02-17T23:00:46Z (9 months ago)
Fibonacci numbers with no consecutive digits
Output the Nth number in the list of Fibonacci numbers that have no consecutive digits.

## Input
- A non-negative integer.

## Output
- The Nth number in the list of Fibonacci numbers whose base 10 (decimal) representation has no adjacent digits that are consecutive.
- Two digits are consecutive if their absolute difference is 1.
- The consecutive digits can be in either ascending or descending order - either will lead to exclusion from the list.

## Examples
### Single digit Fibonacci numbers
- A single digit number has no adjacent digits, so all single digit Fibonacci numbers are included.

### Two digit Fibonacci numbers
- 34 and 89 are excluded because their digits are consecutive.
- 21 is also excluded due to consecutive digits in descending order.

## Test cases
Test cases are in the format `input : output`.

```text
0 : 0
1 : 1
2 : 1
3 : 2
4 : 3
5 : 5
6 : 8
7 : 13
8 : 55
9 : 144
10 : 377
11 : 1597
12 : 2584
13 : 4181
14 : 17711
15 : 46368
16 : 75025
17 : 196418
18 : 514229
19 : 14930352
20 : 39088169
```

## Scoring
This is a [code golf challenge]. Your score is the number of bytes in your code. Lowest score for each language wins.

> Explanations are optional, but I'm more likely to upvote answers that have one.


[code golf challenge]: https://codegolf.codidact.com/categories/49/tags/4274 "The code-golf tag"