セクション 1. 章 22
single
Challenge: Filtering Numbers in a Loop
メニューを表示するにはスワイプしてください
タスク
スワイプしてコーディングを開始
Find the sum of all numbers from 1 to n, excluding those that are divisible by 3 or 5.
- Create a method called
sumNotDivisibleBy3Or5(int n)that returns anint. - Inside this method, create a
forloop that iterates from 1 ton(inclusive). - In each iteration, check if the number is not divisible by 3 and not divisible by 5.
- If the number passes the condition, add it to a running total
sum. - Return the total
sumafter the loop ends.
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 1. 章 22
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください