Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- double log_n(double n) { // Big O(log n) Logarithmic // recursive
- if (n != 0) {
- n = floor(n / 2);
- log_n(n);
- }
- return n;
- }
- int main() {
- std::cout << log_n(8.0) << '\n';
- return 0;
- }
- // returns 4 instead of 3. I thought it was because I used int first but the bug is still here.
- // for 7.0 it returns 3 instead. what am I doing wrong?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement