Advertisement
BSO90

Prime Factors

May 26th, 2021
957
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.41 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Prime_Factors
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             for (int i = 2; i <= n; i++)
  11.             {
  12.                 while (n % i == 0)
  13.                 {
  14.                     n /= i;
  15.                     Console.WriteLine(i);
  16.                 }
  17.             }
  18.         }
  19.     }
  20. }
  21.  
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement