Skip to content

Instantly share code, notes, and snippets.

View juanbecerra0's full-sized avatar
🦊
Pressing F5 to see what happens

Juan Becerra juanbecerra0

🦊
Pressing F5 to see what happens
View GitHub Profile
// Abstract class that other classes can implement
abstract class Item {
use();
}
// Inherits the 'Item' class's 'use()' method
class Box<T> implements Item {
// ADT list that can contain other objects
List<T> contents;
void main() {
print(factorial(1));
print(factorial(5));
print(factorial(10));
print(factorial(20));
}
int factorial(int n) {
if (n <= 1) { // Base case
return 1;