34 lines
612 B
Plaintext
34 lines
612 B
Plaintext
|
void main() {
|
||
|
print('Hello, World!');
|
||
|
}
|
||
|
|
||
|
|
||
|
int factorial(int n) {
|
||
|
if (n == 0 || n == 1) {
|
||
|
return 1;
|
||
|
} else {
|
||
|
return n * factorial(n - 1);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void main() {
|
||
|
int number = 5;
|
||
|
int result = factorial(number);
|
||
|
print('The factorial of $number is $result.');
|
||
|
}
|
||
|
|
||
|
int findMax(List<int> numbers) {
|
||
|
int max = numbers[0];
|
||
|
for (int i = 1; i < numbers.length; i++) {
|
||
|
if (numbers[i] > max) {
|
||
|
max = numbers[i];
|
||
|
}
|
||
|
}
|
||
|
return max;
|
||
|
}
|
||
|
|
||
|
void main() {
|
||
|
List<int> numbers = [12, 56, 3, 78, 42, 9];
|
||
|
int maxNumber = findMax(numbers);
|
||
|
print('The maximum number in the list is $maxNumber.');
|
||
|
}
|