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

Fix undefined_operator in fermats_little_theorem.dart #141

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions maths/fermats_little_theorem.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@Skip('currently failing (see issue #86)')

import 'package:test/test.dart';

/*
Expand All @@ -21,12 +19,22 @@ void main() {
// a prime number
int p = 701;

double a = 1000000000;
Copy link
Member

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 a = 1000000000;
int b = 10;

// using binary exponentiation function, O(log(p)):
print((a / b) % p == (a * binary_exponentiation(b, p - 2, p)) % p);
Copy link
Member

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.


test(
'test 1',
() {
expect(
(a / b) % p == (a * binary_exponentiation(b, p - 2, p) % p), isTrue);
},
);
// using Python operators:
print((a / b) % p == (a * b ^ (p - 2)) % p);
Copy link
Member

Choose a reason for hiding this comment

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

Why remove this?

test(
'test 2',
() {
expect((a / b) % p == (a * b ^ (p - 2)) % p, isFalse);
},
);
}