From f7c60a476513583799ef5114449318cf4f59695f Mon Sep 17 00:00:00 2001 From: nsnk <44540856+nsnk@users.noreply.github.com> Date: Sat, 26 Jan 2019 04:42:37 +0530 Subject: [PATCH] Create choco_wrapers_sum --- src/to_be_organized/choco_wrapers_sum | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/to_be_organized/choco_wrapers_sum diff --git a/src/to_be_organized/choco_wrapers_sum b/src/to_be_organized/choco_wrapers_sum new file mode 100644 index 0000000..d0544a5 --- /dev/null +++ b/src/to_be_organized/choco_wrapers_sum @@ -0,0 +1,24 @@ +use std::io; +//3 chocolates wrapers will give as chocolate +//this is used to find the total no of choclates retained +fn main() +{ + let mut rap:i32=0; + let mut m=String::new(); + io::stdin() + .read_line(&mut m) + .expect("failed to read from stdin"); + + let mut n = m.trim() + .parse::() + .unwrap(); + let mut tot:i32=n; + while n>2 + { + tot=tot+n/3; + rap=n-n/3*3+n/3; + n=rap; + } + println!("no of chocolates={}",tot); + print!("no of wrapers={}",rap); +}