Skip to content

Commit

Permalink
tmp: findPrimeNumber in example
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind committed Sep 15, 2023
1 parent 0badc2a commit a3d53ae
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ class MainScaffold extends StatelessWidget {
status: const SpanStatus.internalError());

await Future.delayed(const Duration(milliseconds: 50));

findPrimeNumber(1000000); // xxx remove - just for testing
await transaction.finish(status: const SpanStatus.ok());
},
child: const Text('Capture transaction'),
Expand Down Expand Up @@ -856,3 +856,24 @@ class ThemeProvider extends ChangeNotifier {
Future<void> execute(String method) async {
await _channel.invokeMethod(method);
}

int findPrimeNumber(int n) {
int count = 0;
int a = 2;
while (count < n) {
int b = 2;
bool prime = true; // to check if found a prime
while (b * b <= a) {
if (a % b == 0) {
prime = false;
break;
}
b++;
}
if (prime) {
count++;
}
a++;
}
return a - 1;
}

0 comments on commit a3d53ae

Please sign in to comment.