-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCollatz.h
72 lines (58 loc) · 1.41 KB
/
Collatz.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// --------------------------
// projects/collatz/Collatz.h
// Copyright (C) 2014
// Glenn P. Downing
// --------------------------
#ifndef Collatz_h
#define Collatz_h
// --------
// includes
// --------
#include <iostream> // istream, ostream
#include <utility> // pair
// ------------
// collatz_read
// ------------
/**
* read two ints
* @param r an std::istream
* @return a pair of ints, representing the beginning and end of a range, [i, j]
*/
std::pair<int, int> collatz_read (std::istream& r);
// ------------
// collatz_eval
// ------------
/**
* @param i the beginning of the range, inclusive
* @param j the end of the range, inclusive
* @return the max cycle length of the range [i, j]
*/
int collatz_eval (int i, int j);
// ------------
// collatz_cycle_length
// ------------
/**
* @param i the number who's cycle length we want to calculate
* @return the cycle length of i
*/
int collatz_cycle_length (int n);
// -------------
// collatz_print
// -------------
/**
* print three ints
* @param w an std::ostream
* @param i the beginning of the range, inclusive
* @param j the end of the range, inclusive
* @param v the max cycle length
*/
void collatz_print (std::ostream& w, int i, int j, int v);
// -------------
// collatz_solve
// -------------
/**
* @param r an std::istream
* @param w an std::ostream
*/
void collatz_solve (std::istream& r, std::ostream& w);
#endif // Collatz_h