fibonacci/solution.c: prints negative numbers for n of 47 or more (F(90) prints -1581614984)
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 25/100
Research direction
Start in problems/fibonacci/solution.c, where the value is computed in a type too narrow for F(47) and above, and compare with the Go, C++ and Python solutions. Add the failing inputs (47, 79, 90) to problems/fibonacci/cases.txt, then run python3 run.py fibonacci. Done when those inputs print 2971215073, 14472334024676221 and 2880067194370816120. Pull request #31 is already open against this, so check it before starting.
Written by the indexing model from the issue text.
Description
What I did
- Fresh checkout of
main, a C compiler. - Compile and run the C solution:
cd problems/fibonacci
gcc solution.c -o fib
echo 46 | ./fib
echo 47 | ./fib
echo 79 | ./fib
echo 90 | ./fib
What I expected
The problem README says: "Read n (0 <= n <= 90) and print the nth Fibonacci number ... F(90) is 2880067194370816120, so think about which number type can hold it." (problems/fibonacci/README.md)
So 47 should print 2971215073, 79 should print 14472334024676221, and 90 should print 2880067194370816120.
What happened instead
46 -> 1836311903 (correct)
47 -> -1323752223
79 -> -660827267
90 -> -1581614984
Every n from 47 to 90 is wrong. The Go, C++ and Python solutions print the correct values. python3 run.py fibonacci passes today because cases.txt has no input above 46.
Environment
code-corner main @ 0c95800, gcc 16.2, Windows 11.
I'd like to work on the fix for this, and add the failing inputs to cases.txt as the Contributing section asks.
- Dominant language
- Python
- Stars
- 1
- Forks
- 6
- Avg merge
- 17h 52m
- Merged PRs (30d)
- 14
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from techcsispit/code-corner
-
prime/solution.java doesn't compile: public class PrimeCheck in solution.java, README requires Solution.java with a Solution classPossibly taken @tanujb03 claimed this 2 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 82/100
techcsispit/code-corner#35 ·
Maintainers usually reply within 1 day
-
Prime solution in C++ incorrectly returns true for some composite numbersPossibly taken @paramsj claimed this 2 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 25/100
techcsispit/code-corner#38 ·
Maintainers usually reply within 1 day
-
Failed compilations always report 0.000 secondsPossibly taken @Shivangi-singh18 claimed this 2 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
techcsispit/code-corner#37 · 1 comment ·
Maintainers usually reply within 1 day
-
run.py: Python solutions are skipped on Windows when run via python instead of python3Possibly taken @tanujb03 claimed this 2 days ago. Openbug good first issue
Difficulty 1/5 Under an hour Newbie friendliness 15/100
techcsispit/code-corner#29 ·
Maintainers usually reply within 1 day
-
binary-search/Solution.java: prints -1 when the target is the last element (`9 1 3 5 7 9`) or in a 1-element list (`5 5`)Possibly taken @tanujb03 claimed this 3 days ago. Openbug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 22/100
techcsispit/code-corner#26 ·
Maintainers usually reply within 1 day
All issues in techcsispit/code-corner
Similar issues
-
area: agents area: docs good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
openapi/gknowledge#23 ·
-
get() for StrEnumPossibly taken @FeJo5952 claimed this today. Opengood first issue
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
collective/icalendar#1921 · 1 comment ·
Maintainers usually reply within 1 day
-
Improvement Python Spans
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
getsentry/sentry-python#7994 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
alphagov/notifications-api#5004 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
equinor/radix-flux#3922 ·
Maintainers usually reply within 1 day