-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop.dart
More file actions
44 lines (34 loc) · 825 Bytes
/
loop.dart
File metadata and controls
44 lines (34 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
int fibonacci(int val) {
if (val == 0 || val == 1) {
return val;
}
return (fibonacci(val - 1)) + (fibonacci(val - 2));
}
int factorial(int val) {
if (val == 0) {
return 1;
}
return val * factorial(val - 1);
}
void main() {
List num = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
// for (var each in num) {
// print(each);
// }
num.where((element) => num.contains(element)).forEach((element) {
print(element);
});
List name = ["John", "Doe", "Jane", "Doe"];
// while (name.length > i) {
// print(name[i]);
// i++;
// }
// name.where((element) => name.contains(element)).forEach((element) {
// print(element);
// });
name.where((element) => name.contains(element)).forEach((element) {
print(element);
});
// print(factorial(10));
// print(fibonacci(20));
}