successives operations with C++
Posted
by
Tayeb Ghagha
on Stack Overflow
See other posts from Stack Overflow
or by Tayeb Ghagha
Published on 2013-10-29T12:37:22Z
Indexed on
2013/11/02
3:54 UTC
Read the original article
Hit count: 130
How can I perform this code:
if a number n is divisible by 3, add 4 to n;
if n is not divisible by 3 but by 4, divise n by 2;
if n is not divisible by 3, not by 4, make n=n-1.
The problem with me is that I don't know how to make this successively. For example: with the number 6, I have to have:
6, 10, 9, 13, 12, 16, 8, 4, 2, 1 et 0
6+4=10; 10-1=9; 9+4=13; 13-1=12; 12+4=16; 16/2=8.....0
This makes 10 operations.
So my program has to return: 6---10
Thank you for help
© Stack Overflow or respective owner