Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ExerciceAlgo
- {
- class Program
- {
- static void Main(string[] args)
- {
- while (1== 1)
- {
- menu();
- }
- }
- public static void menu()
- {
- Console.WriteLine("Chosir nb à tester");
- int nb = 0;
- nb= int.Parse(Console.ReadLine());
- int i = 0;
- while (nb != 1)
- {
- nb= Syracuse(nb);
- i++;
- }
- Console.WriteLine("Temps de vol : {0}", i);
- }
- public static int Syracuse(int nb)
- {
- if (nb > 0)
- {
- if ((nb%2)==0)
- {
- return nb / 2;
- }
- else
- {
- return nb * 3 + 1;
- }
- }
- return 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement