Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Conjecture, not contique
- */
- using System;
- using System.Threading;
- namespace Collatz_Conjecture
- {
- class Program
- {
- public static void Main()
- {
- double read;
- Console.WriteLine("Напиши число и я сделаю сиракузскую последовательность этого числа");
- if (double.TryParse(Console.ReadLine(),out read)){
- Siracuse(read,1);
- Console.ReadKey();
- }
- }
- public static bool IsOdd(double val)
- {
- if (val % 2 != 0){
- return true;
- }
- else {
- return false;
- }
- }
- public static void Siracuse(double value, int sleep)
- {
- while (value != 1){
- if (IsOdd(value)){
- value = value * 3 + 1;
- }
- else {
- value = value / 2;
- }
- Console.Write(value + " ");
- Thread.Sleep(sleep);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment