Count in factors: Difference between revisions
Content added Content deleted
(add task to arm assembly raspberry pi) |
(C++: to_string) |
||
Line 984: | Line 984: | ||
=={{header|C++}}== |
=={{header|C++}}== |
||
<lang |
<lang cpp>#include <iostream> |
||
#include <iostream> |
|||
#include <sstream> |
|||
#include <iomanip> |
#include <iomanip> |
||
using namespace std; |
using namespace std; |
||
Line 993: | Line 991: | ||
{ |
{ |
||
int f = 2; string res; |
int f = 2; string res; |
||
if( li == 1 ) res = "1"; |
if ( li == 1 ) res = "1"; |
||
else |
else |
||
{ |
{ |
||
while( true ) |
while ( true ) |
||
{ |
{ |
||
if( !( li % f ) ) |
if( !( li % f ) ) |
||
{ |
{ |
||
⚫ | |||
stringstream ss; ss << f; |
|||
⚫ | |||
li /= f; if( li == 1 ) break; |
li /= f; if( li == 1 ) break; |
||
res += " x "; |
res += " x "; |
||
Line 1,013: | Line 1,010: | ||
int main( int argc, char* argv[] ) |
int main( int argc, char* argv[] ) |
||
{ |
{ |
||
for( int x = 1; x < 101; x++ ) |
for ( int x = 1; x < 101; x++ ) |
||
{ |
{ |
||
cout << right << setw( 4 ) << x << ": "; |
cout << right << setw( 4 ) << x << ": "; |
||
Line 1,021: | Line 1,018: | ||
cout << "\n\n"; |
cout << "\n\n"; |
||
return system( "pause" ); |
return system( "pause" ); |
||
⚫ | |||
} |
|||
⚫ | |||
{{out}} |
{{out}} |
||
<pre> |
<pre> |