Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Problem17
- {
- class Program
- {
- static void Main(string[] args)
- {
- int t = int.Parse(Console.ReadLine());
- for (int i = 0; i < t; i++)
- {
- int s = int.Parse(Console.ReadLine());
- Console.WriteLine(Oblicz(s,0));
- }
- }
- private static int Oblicz(int s, int n)
- {
- if (s == 1)
- {
- return n;
- }
- else
- {
- if (s % 2 == 1)
- {
- return Oblicz(3 * s + 1, ++n);
- }
- else
- {
- return Oblicz(s / 2, ++n);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement