#include <stdio.h> #include <iostream> #include <math.h> using namespace std; bool is_prime(int num) { if (num < 2) return false; for (int i = 2; i < num; i++){ if (num % i == 0) return false; } return true; } int main(void) { int number; cin >> number; if (number < 2) { cout << "Please give a number bigger than 2" << endl; return 0; } if (is_prime(number)){ cout << number << endl; return 0; } int prime_list[1000] = {0}; int prime_count = 0; for (int i = 2; i <= number; i++){ if (is_prime(i)){ prime_list[++prime_count] = i; } } int factor_list[1000] = {0}; int factor_count = 0; int number_divided = number; int i = 1; while (number_divided != 1){ int divider = prime_list[i]; while(true){ if (number_divided % divider == 0){ factor_list[++factor_count] = divider; number_divided /= divider; } else { i++; break; } } } for (int i = 1; i <= factor_count; i++){ cout << factor_list[i] << ' '; } cout << endl; return 0; }