Loading [MathJax]/extensions/tex2jax.js
Parallel numerical verification of the σ_odd problem  October 6, 2018
All Classes Namespaces Files Functions Variables Typedefs Macros
harmonic__inline.hpp
Go to the documentation of this file.
1 /* -*- coding: latin-1 -*- */
2 /** \file common/sigmaodd/harmonic__inline.hpp (December 20, 2017)
3  *
4  * GPLv3 --- Copyright (C) 2017 Olivier Pirson
5  * http://www.opimedia.be/
6  */
7 
8 #ifndef PROGS_SRC_COMMON_SIGMAODD_HARMONIC__INLINE_HPP_
9 #define PROGS_SRC_COMMON_SIGMAODD_HARMONIC__INLINE_HPP_
10 
11 
12 namespace sigmaodd {
13 
14  /* *********************
15  * constexpr functions *
16  ***********************/
17 
18  constexpr
19  double
21  double h = 0;
22 
23  for (nat_type i = 1; i <= n; ++i) {
24  h += 1.0/static_cast<double>(i);
25  }
26 
27  return h;
28  }
29 
30 
31  constexpr
32  double
34  return harmonic(n >> 1)/2;
35  }
36 
37 
38  constexpr
39  double
41  double h = 0;
42 
43  for (nat_type i = 1; i <= n; i += 2) {
44  h += 1.0/static_cast<double>(i);
45  }
46 
47  return h;
48  }
49 
50 } // namespace sigmaodd
51 
52 #endif // PROGS_SRC_COMMON_SIGMAODD_HARMONIC__INLINE_HPP_
uint64_t nat_type
Type for natural number used in all code, on 64 bits.
Definition: helper.hpp:33
A lot of functions and stuffs to deal the sigma_odd problem and related stuffs.
Definition: divisors.cpp:22
constexpr double harmonic_even(nat_type n)
Return 1/2 + 1/4 + 1/6 + 1/8 + ... + (1/n or 1/(n-1)).
constexpr double harmonic(nat_type n)
Return the harmonic number H_n = 1/1 + 1/2 + 1/3 + 1/4 + ... + 1/n.
constexpr double harmonic_odd(nat_type n)
Return 1/1 + 1/3 + 1/5 + 1/7 + ... + (1/n or 1/(n-1)).