SWEA 1933 간단한 N 의 약수

Jmnote (토론 | 기여)님의 2023년 8월 25일 (금) 01:42 판
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

SWEA 1933 간단한 N 의 약수

2 C++[ | ]

#include <iostream>
using namespace std;
int main() {
    int N;
    cin >> N;
    for(int i=1; i<=N; i++) {
        if( N%i != 0 ) continue;
        cout << i << " ";
    }
}

3 Java[ | ]

import java.util.Scanner;
class Solution {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        for(int i=1; i<=N; i++) {
            if( N % i != 0 ) continue;
            System.out.format("%d ", i);
        }
    }
}

4 Python[ | ]

#kcy
k = int(input())
for i in range(1, k+1):
    if k % i == 0:
        print(i, end=' ')
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}