코딩Coding/Rust연습
Rust연습_Fibonacci피보나치 출력
내인생PLUS
2021. 5. 13. 01:15
728x90
fn main() {
let mut i = 0;
let mut a = 0;
let mut c = 0;
let mut b = 1;
while i < 20 {
if i > 1 {
c = b; //1//1/2//3
b = b + a; //1+0=1/1+1=2////3
a = c; //1//1//2
println!(" {}", b);
i = i + 1;
} else {
println!(" {}", i);
i = i + 1;
}
}
}
결과
www.youtube.com/watch?v=WgWrqLwMIgU
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | fn main() { let mut i = 0; let mut a = 0; let mut c = 0; let mut b = 1; while i < 20 { if i > 1 { c = b; //1//1/2//3 b = b + a; //1+0=1/1+1=2////3 a = c; //1//1//2 println!(" {}", b); i = i + 1; } else { println!(" {}", i); i = i + 1; } } } | cs |
반응형