Main/Test

34 lines
612 B
Plaintext
Raw Normal View History

2023-07-26 17:14:59 +00:00
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.');
}