Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Say if number is prime and give its factors
//Microsoft (R) C/C++ Optimizing Compiler Version 19.00.23506 for x86 #include <iostream> int factors(int num); int main() { int num{25}; std::cout << (factors(num) >2? " ==> not prime number " : " ==> prime number") << std::endl; //factors(num); return 0; } int factors(int num) { std::cout << "Factors of " << num << " are : "; int countFactors{0}; for(int i = 1; i <= num; i++){ if(num%i == 0){ std::cout << i << " "; ++countFactors; } } return countFactors; }
run
|
edit
|
history
|
help
0
😊
VC++ Template Comment
derived_tempalte
zero size std::array parameter
infix to postfix v 2.0
ntohl
imdying
_countof constexpr
VS struct name enumerate
Regex pipe and tabs c++