#!/bin/bash #計算100以內所有能被3整除的正整數的和 #定義和變量 let SUM = 0 for I in {1..100}; do #取余運算 if [ $[$I%3] -eq 0 ]; then SUM=$[$SUM+$I] fi done echo ...
對 以內的所有正整數相加求和 ... ...
2019-10-14 16:09 0 655 推薦指數:
#!/bin/bash #計算100以內所有能被3整除的正整數的和 #定義和變量 let SUM = 0 for I in {1..100}; do #取余運算 if [ $[$I%3] -eq 0 ]; then SUM=$[$SUM+$I] fi done echo ...
【腳本5】數字求和 編寫shell腳本,要求輸入一個數字,然后計算出從1到輸入數字的和,要求,如果輸入的數字小於1,則重新輸入,直到輸入正確的數字為止,示例: 一、腳本 二、小結: 1、for 循環 [1]LInux shell之(for in 用法總結) https ...
100以內所有能被3整除的列表 100以內所有能被3整除的整數的和 方法一: 方法二: ...
/* 使用for循環,實現1~100所有奇數求和*/public class 1~100所有奇數求和{ public static void main(String[] args){ int n = 0; int i = 1; for(; i <= 100;i ...
1 這里引用了 hutool 依賴 <dependency> <groupId>io.github.openfeign</group ...
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; //找出100以內的所有孿生質數的代碼namespace ...
<?php //產生1~100的正整數 $numbers = range(1,100); //從1~100中選出10個不重復的整數,並使用函數進行排序 $randNumbers = array_rand($numers,10); print_r($randNumbers); ...