Exclusive Multiples of 3 or 5


Submit solution

Points: 10
Time limit: 1.0s
Memory limit: 10M

Author:
Problem type

Description

請撰寫一個程式,輸入一個正整數 n,並使用 for loop 在 1 ~ n 之間找出所有同時符合以下條件的數字:

  • 3 的倍數
  • 或是 5 的倍數
  • 不能同時是 3 和 5 的倍數

Requirements

  1. 輸入

    • 一個正整數 n,已知 1 ≤ n ≤ 10000
  2. 輸出

  • 第一行:符合條件的數量
  • 第二行:符合條件的總和
  • 第三行:符合條件的最大值,若沒有符合條件的數字則輸出 0

Input and Output

Sample 1 Sample 2 Sample 3
INPUT 10 15 2
OUTPUT 5
33
10
6
45
14
0
0
0

Explanation

以 Sample 1 為例,103 的倍數有 3, 6, 9,在 5 的倍數有 5, 10,且 3 + 5 + 6 + 9 + 10 = 33,其中最大值為 10。


Comments

There are no comments at the moment.