2018-06-24 15:53:27 -05:00
|
|
|
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
#![feature(const_let)]
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// Tests the Collatz conjecture with an incorrect base case (0 instead of 1).
|
|
|
|
// The value of `n` will loop indefinitely (4 - 2 - 1 - 4).
|
|
|
|
let _ = [(); {
|
|
|
|
//~^ WARNING Constant evaluating a complex constant, this might take some time
|
|
|
|
//~| ERROR could not evaluate repeat length
|
2018-06-29 15:32:54 -05:00
|
|
|
let mut n = 113383; // #20 in https://oeis.org/A006884
|
2018-06-24 15:53:27 -05:00
|
|
|
while n != 0 { //~ ERROR constant contains unimplemented expression type
|
|
|
|
n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
|
|
|
|
}
|
|
|
|
n
|
|
|
|
}];
|
|
|
|
}
|