Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# prime factorization

class Program
{
    static void Main(string[] args)
    {
        int a, b;
        Console.WriteLine("Please enter your integer: ");
        a = int.Parse(Console.ReadLine());
        for (b = 1; b <= a; b++)
        {
            if (a % b == 0)
            {
                Console.WriteLine(b + " is a factor of " + a);
            }
        }
    }
}
Comment

c# prime factorization


int a, b;
Console.WriteLine("Please enter your integer: ");
a = int.Parse(Console.ReadLine());

for (b = 2; a > 1; b++)
    if (a % b == 0)
    {
        int x = 0;
        while (a % b == 0)
        {
            a /= b;
            x++;
        }
        Console.WriteLine($"{b} is a prime factor {x} times!");
    }
Console.WriteLine("Th-Th-Th-Th-Th-... That's all, folks!");

Comment

PREVIOUS NEXT
Code Example
Csharp :: unity get gameobject script is attached to 
Csharp :: get date from file c# 
Csharp :: get random number c# 
Csharp :: unity serializefield 
Csharp :: stop process c# 
Csharp :: defaultconnection appsettings.json 
Csharp :: unity mouse wheel 
Csharp :: add row to datagridview c# 
Csharp :: c# string to datetime 
Csharp :: unity how to load up a scene 
Csharp :: unity character controller ignore collision 
Csharp :: base64 bit string to pdf c# 
Csharp :: backcolor c# hexadecimal 
Csharp :: wpf set image source in code behind 
Csharp :: unity text display int 
Csharp :: c# create datatable 
Csharp :: how to store more precise data then double c# 
Csharp :: c# string to uri 
Csharp :: byte to stream c# 
Csharp :: how to get the time since play unity 
Csharp :: unity agent walks in place at start 
Csharp :: unity camera follow 
Csharp :: c# checksum 
Csharp :: no move arrows unity 
Csharp :: unity 2d looka tt mouse 
Csharp :: pass datatable to stored procedure c# dapper 
Csharp :: unity c# set object tag 
Csharp :: how to draw gizmos unity 
Csharp :: c# @ before string 
Csharp :: c# shuffle array 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =