

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# program to display factors of entered number
Firstly, enter the number for which you want the factors −
Console.WriteLine("Enter the Number:"); n = int.Parse(Console.ReadLine());
After that, loop through to find the factors −
for (i = 1; i <= n; i++) { if (n % i == 0) { Console.WriteLine(i); } }
Example
You can try to run the following code to display factors of a number −
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Demo { class ApplicationOne { static void Main(string[] args) { int n, i; Console.WriteLine("Enter the Number:"); n = int.Parse(Console.ReadLine()); Console.WriteLine("Factors:"); for (i = 1; i <= n; i++) { if (n % i == 0) { Console.WriteLine(i); } } Console.ReadLine(); } } }
- Related Questions & Answers
- C# Program to display the Factors of the Entered Number
- C++ Program to Display Factors of a Number
- Java Program to Display Factors of a Number
- C++ Program to Print Number Entered by User
- C++ Program to find sum of even factors of a number?
- Java Program to find minimum sum of factors of a number
- Java Program to Find sum of even factors of a number
- Program to find number of values factors of two set of numbers
- Python Program for Find minimum sum of factors of number
- To find sum of even factors of a number in C++ Program?
- C Program to Find the minimum sum of factors of a number?
- Java Program to find Product of unique prime factors of a number
- Count number of factors of a number - JavaScript
- Write a C# program to check if the entered number is Armstrong number?
- C Program for Find sum of odd factors of a number?
Advertisements