Menu
Coddy logo textTech

A problem

Coddy의 수학 수수께끼 코스 레슨 — 20개 중 2번째.

10 미만의 자연수 중에서 3 또는 5의 배수를 나열하면 3, 5, 6, 9입니다.

이 배수들의 23 (3 + 5 + 6 + 9 = 23)입니다.

100 미만, 1000 미만인 3 또는 5의 배수의 합을 모두 구하세요...

challenge icon

챌린지

쉬움

정수 N을 입력으로 받아 N 미만의 3 또는 5의 배수의 합을 반환하는 함수 calc를 작성하세요.

예를 들어 N=10인 경우, 3 + 5 + 6 + 9 = 23이므로 함수는 23을 반환합니다.

직접 해보기

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include "solution.h"

int main() {
    int n;
    if (scanf("%d", &n) != 1) n = 0;
    int r = calc(n);
    printf("%d\n", r);
    return 0;
}

수학 수수께끼의 모든 레슨

2Multiples of 3 or 5

A problemA solution with no loops

5Diophantine Equation

IntroductionA problem