c++ - Collatz sequence algorithm not working right -
For some reason, it always returns 1 value. This means that the initial number (1-1, 000,000) is the longest edge (till Jammu = 1) Jammu will always be finally 1 (Cologet's theory) , I divide Jammu by 2 if Be it too, or more than 3 and add 1 if it's odd. You are not calling your work , You are printing the function pointer (which is converted to
Add # & lt; Iostream & gt; using namespace std; Int callouts () {int counter = 0; Int holder = 0; (Int i = 999999; i & gt; 1; i -) {// loops 999,999 times (int j = i; j! = 1; counter ++) {// loops of jops = 1 to loops, when To loops (j% 2 == 0) {// If J is also, then divide by 2, to +1 j = j / 2; } And {J = (J3) + 1; // If j is weird, multiply by 3 and add 1, counter to 1}} if (holder
bool value
true (that is,
1 )).
Comments
Post a Comment