Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Fibonacci in Nim #1670

Merged
merged 8 commits into from
Oct 17, 2019
Merged

Added Fibonacci in Nim #1670

merged 8 commits into from
Oct 17, 2019

Conversation

MichaelAOlson
Copy link
Contributor

Code Snippets

  • I named the pull request using Added/Updated <Sample Program> in <Language> format
  • I created/updated the language README
    • I added the sample program name to the README
    • I added fun facts (i.e. debut, developer, typing, etc.)
    • I added reference link(s) to the README
    • I added solution citations when necessary (see [plagiarism][2])

Copy link
Member

@jrg94 jrg94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance you could pull the latest changes from master? I just setup Nim for testing in #1667.

@jrg94 jrg94 self-assigned this Oct 17, 2019
@jrg94 jrg94 added enhancement Any code that improves the repo fibonacci See: https://sampleprograms.io/projects/fibonacci/ hacktoberfest Hacktoberfest related labels Oct 17, 2019
@jrg94 jrg94 added this to the 500 Code Snippets milestone Oct 17, 2019
# Fibonacci Sample Program in Nim
import strutils

echo "Input the number of iterations (n): "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this program, I'd take a peek at the requirements: https://sample-programs.therenegadecoder.com/projects/fibonacci/

We typically don't prompt for input. Instead, we pull it directly off the command line. Does Nim support command line args?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah once I saw the build failed I started looking into that. There are a number of ways, just trying to figure out an os-agnostic method.

@jrg94
Copy link
Member

jrg94 commented Oct 17, 2019

Just took a peek at your tests. Everything looks great! At this point, it's an output formatting issue. We print all terms in the sequence in order by index:

1: 1
2: 1
3: 2
4: 3
5: 5

echo "Usage: please input the count of fibonacci numbers to output"
quit(1)
except ValueError:
echo "invalid input: not a number"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use the same string for both cases. Sorry if that was confusing in the table.

Suggested change
echo "invalid input: not a number"
echo "Usage: please input the count of fibonacci numbers to output"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@MichaelAOlson
Copy link
Contributor Author

MichaelAOlson commented Oct 17, 2019 via email

Copy link
Member

@jrg94 jrg94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@jrg94 jrg94 merged commit 0d6715e into TheRenegadeCoder:master Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Any code that improves the repo fibonacci See: https://sampleprograms.io/projects/fibonacci/ hacktoberfest Hacktoberfest related
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add Fibonacci in Nim
3 participants