Created
January 17, 2015 10:34
-
-
Save hi2p-perim/94cc7a0a105678c30cf6 to your computer and use it in GitHub Desktop.
Composite numbers that Cocoa-chan should be careful to remember (cf. Gochiusa episode #10)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
int main() | |
{ | |
for (int n = 2; n <= 9719; n++) | |
{ | |
bool found = false; | |
int nn = n; | |
std::vector<int> a; | |
for (int i = 2; i*i < n; i++) | |
{ | |
int v = 0; | |
while (nn % i == 0) | |
{ | |
a.push_back(i); | |
nn /= i; | |
} | |
} | |
if (nn != 1) a.push_back(nn); | |
if (a.size() >= 2) | |
{ | |
int cnt = 0; | |
for (int v : a) | |
{ | |
// Assume that Cocoa-chan can instantly determine | |
// if a given number can be divisible by prime numbers smaller than 50 | |
if (v > 50) cnt++; | |
} | |
if (cnt >= 2) | |
{ | |
std::cout << n << " = "; | |
for (int v : a) std::cout << v << " "; | |
std::cout << std::endl; | |
} | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment