-
-
Notifications
You must be signed in to change notification settings - Fork 445
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
Fix undefined_operator in fermats_little_theorem.dart #141
Conversation
fixed issue TheAlgorithms#86 added test cases @cclauss @Parowicz @StepfenShawn
maths/fermats_little_theorem.dart
Outdated
@@ -21,12 +19,22 @@ void main() { | |||
// a prime number | |||
int p = 701; | |||
|
|||
double a = 1000000000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing support for floating point numbers seems like a step too far. Is there a way to keep supporting floating point numbers? Tests should cover positive numbers, negative numbers, and zero as well as floating point numbers if we keep supporting them.
int b = 10; | ||
|
||
// using binary exponentiation function, O(log(p)): | ||
print((a / b) % p == (a * binary_exponentiation(b, p - 2, p)) % p); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this? When the visitor runs this program then nothing visible will happen. We are writing these programs primarily for readers to understand and secondarily for computers to test.
// using Python operators: | ||
print((a / b) % p == (a * b ^ (p - 2)) % p); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this?
Added the suggested changes Added print statements Added support for double
fixed dart format issues
Tests should cover positive numbers, negative numbers, and zero as well as floating-point numbers. |
Fixes #86
added test cases
@cclauss @Parowicz @StepfenShawn
Welcome to Dart community
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}
.