Last active
April 18, 2018 12:05
-
-
Save mrtycjan/bb25dfcdb3c3a0623abd64d6f391b528 to your computer and use it in GitHub Desktop.
binarnie pl algorytm rozkładu liczby na czynniki pierwsze
This file contains 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> | |
//rozklad liczb na czynniki pierwsze | |
//Tycjan Sobel 2018 | |
using namespace std; | |
int main() | |
{ | |
int liczba; | |
int dzielnik = 2; | |
cout << "Podaj liczbę całkowitą: "; | |
cin >> liczba; | |
int dzielna = liczba; | |
cout << "Czynniki pierwsze tej liczby: "; | |
while (liczba / dzielnik != 1) | |
{ | |
if(dzielna % dzielnik == 0){ | |
dzielna = dzielna / dzielnik; | |
cout<<dzielnik<<" "; | |
} else { | |
dzielnik++; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment