백준 11653 c++

magicdrill·2024년 4월 4일
0

백준 문제풀이

목록 보기
259/655

백준 11653 c++

#include <iostream>

using namespace std;

int input(int lower, int upper);
void factorization(int N);

int main(void)
{
	int N;

	N = input(1, 10000000);
	factorization(N);

	return 0;
}

int input(int lower, int upper)
{
	int A;

	while (1)
	{
		cin >> A;
		if (A >= lower && A <= 10000000)
		{
			break;
		}
		else
		{
			;
		}
	}

	return A;
}

void factorization(int N)
{
	int i = 2;

	while (N != 1)
	{
		if (N % i == 0)
		{
			N = N / i;
			cout << i << endl;
		}
		else
		{
			i++;
		}
	}

	return;
}

0개의 댓글