Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- std::vector<unsigned long> obliczUlamekLancuchowy(unsigned long liczba) {
- unsigned long r = floor(sqrt(liczba));
- unsigned long a = r;
- unsigned long p = 0;
- unsigned long q = 1;
- std::vector<unsigned long> vector;
- vector.push_back(r);
- do {
- p = a * q - p;
- q = (liczba - p * p) / q;
- a = (r + p) / q;
- vector.push_back(a);
- } while (q != 1);
- return vector;
- }
- int main(int argc, char* argv[])
- {
- long liczba;
- std::cin >> liczba;
- std::vector<unsigned long> vector = obliczUlamekLancuchowy(liczba);
- for (unsigned long numer : vector)
- {
- printf("%lu ", numer);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement