Dart编程实例 - while 循环

本文为大家分享 Dart编程实例 - while 循环 的具体示例代码,提供大家参考,具体内容如下:

void main() {
   var num = 5;
   var factorial = 1;
   while(num >=1) {
      factorial = factorial * num;
      num--;
   }
   print("The factorial  is ${factorial}");
}

本文为大家分享 Dart编程实例 - do while 循环 的具体示例代码,提供大家参考,具体内容如下:void main() { var n = 10; do { print(n); n ...