Computer Science, asked by ritammukherjee488, 1 month ago

write a program to accept a number, display all it factors.​

Answers

Answered by CoderRishav
3

Answer:

Hi buddy,

first of all , if you want correct answer then please give question in detail, I mean in which language you want it. The language whatever I know I will answer on that :)

Java

import java.util.Scanner;

class Factor {

public static void main() {

Scanner in = new Scanner(System.in);

int n = in.nextInt();

for (int i=1 ; i<=n ; i++) {

if (n%i==0) {

System.out.println(i);

}

}

}

}

Python

n = int(input())

for i in range(1,n+1):

if n%i == 0:

print(i)

C

#include <stdio.h>

int main() {

int n, i;

scanf("%d",&n);

for(i=1 ; i<=n; i++) {

if (n % i == 0) {

printf("%d\n",i);

}

}

return 0;

}

JavaScript

let input = document.getElementId('inp').value

for (let i=1 ; i<=input; i++)

{

if (input % i == 0)

console.log(i)

}

Golang

package main

import "fmt"

func main() {

n := fmt.Scanln()

for i:=0 ; i<=n; i++ {

if (n%i==0) {

fmt.Println(i)

}

}

}

Kotlin

fun main() {

int n = readLine()!!.toInt()

for (int i in 1..n) {

if (n%i==0)

println(i)

}

}

Regards,

Rishav Tiwari

Similar questions
Math, 25 days ago