Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Say if number is prime and give its factors
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//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; }
cl.exe
Show compiler warnings
[
+
] Compiler args
[
+
]
Show input
Compilation time: 1,9 sec, absolute running time: 0,22 sec, absolute service time: 2,13 sec
fork mode
|
history
|
discussion
Factors of 25 are : 1 5 25 |==> not prime number