Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- template<typename integer>
- integer collatz(integer n) {
- while (1) {
- if (n==1) return 1;
- if (n%2==0) n /= 2;
- else n = 3*n + 1;
- }
- }
- int main() {
- cout << collatz(-1) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement