-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCollatz.h
executable file
·87 lines (72 loc) · 1.75 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// --------------------------
// projects/collatz/Collatz.h
// Copyright (C) 2013
// Glenn P. Downing
// --------------------------
#ifndef Collatz_h
#define Collatz_h
#define CACHE_SIZE 10000000
//#define CACHE_SIZE 56991483520
// --------
// includes
// --------
#include <iostream> // istream, ostream
// ------------
// collatz_read
// ------------
/**
* reads two ints into i and j
* @param r a std::istream
* @param i an int by reference
* @param j an int by reference
* @return true if that succeeds, false otherwise
*/
bool collatz_read (std::istream&, int&, int&);
// ------------
// collatz_lazy_cache
// -----------
/**
* stores lazy cache
* @param num for which collatz length is required
* @return int collatz sequence length for input
*/
int collatz_lazy_cache(unsigned int);
// ------------
// collatz_compute
// -----------
/**
* computes collatz length
* @param num for which collatz length is required
* @return int length of collatz sequence for input
*/
int collatz_compute(unsigned int);
// ------------
// collatz_eval
// ------------
/**
* @param i the beginning of the range, inclusive
* @param j the end of the range, inclusive
* @return the max cycle length in the range [i, j]
*/
int collatz_eval (int, int);
// -------------
// collatz_print
// -------------
/**
* prints the values of i, j, and v
* @param w a 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&, int, int, int);
// -------------
// collatz_solve
// -------------
/**
* read, eval, print loop
* @param r a std::istream
* @param w a std::ostream
*/
void collatz_solve (std::istream&, std::ostream&);
#endif // Collatz_h