Selective operation loop in cpp? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

Selective operation loop in cpp?

How can I create a loop in cpp such that if a given number is even, it divides it by 2 and if it is odd it multiplies it by 3 and adds 1 (3n+1)stuff until the number becomes 1 ?(I want all the values in between).

8th Aug 2021, 4:46 AM
Ishan Kumar Gupta
Ishan Kumar Gupta - avatar
1 Réponse
8th Aug 2021, 5:15 AM
JaScript
JaScript - avatar