DEV Community

Discussion on: Daily Challenge #201 - Complete the Pattern

Collapse
 
exts profile image
Lamonte

Dart, didn't bother to deal with the float and use dynamic

void pattern(int n) {
  if(n < 1) {
    print(" ");
  }
  for(var x = 1; x < n+1; x++) {
    print(x.toString() * x);
  }
}

pattern(4);
pattern(8);
// pattern(0.5); // fails, not an int lol

// 1
// 22
// 333
// 4444
// 1
// 22
// 333
// 4444
// 55555
// 666666
// 7777777
// 88888888