#include<stdio.h>
int main()
{
int divisor, input; // Declare variables
printf("Enter an integer :"); // Ask user to enter
input
scanf("%d", &input); // Read input from
terminal
for(divisor=1; divisor<=input/2; divisor++) //Loop
from 1 to input/2
{
if(input%divisor == 0) //Check if
it is a proper divisor
printf("%d ",
divisor); //If yes, then print it
}
printf("\b\n"); //Remove the extra whitespace at end
and print newline
return 0; //return success
}

Note : The program is done under linux environment. Please note that the program won't display any output for numbers which don't have a proper divisor. And I am assuming the input to be positive. For negative input, add a check after taking input, to return if number is negative. Thanks. Ping me back for any queries/help.
// A O(sqrt(n)) program that prints all divisors
// in sorted order
#include <bits/stdc++.h>
using namespace std;
// function to print the divisors
void printDivisors(int n)
{
// Vector to store half of the divisors
vector<int> v;
for (int i = 1; i <= sqrt(n); i++) {
if (n % i == 0) {
// check if divisors are equal
if (n / i == i)
printf("%d ", i);
else {
printf("%d ", i);
// push the second divisor in the vector
v.push_back(n / i);
}
}
}
// The vector will be printed in reverse
for (int i = v.size() - 1; i >= 0; i--)
printf("%d ", v[i]);
}
/* Driver program to test above function */
int main()
{
printf("The divisors of 100 are: \n");
printDivisors(100);
return 0;
}Need help programing this in C. rinteivsors Print the proper divisors of an integer value The...
a) Write a program that uses a while loop to print all divisors of a number supplied by the user. The program should also print the sum of all the divisors and whether the number the user entered is a prime number or not. Note: The definition of a divisor is a number that divides another evenly (i.e., without a remainder) and the definition of a prime number is a number whose only divisors are 1 and itself. b) Implement...
A perfect number is a positive integer that is equal to the sum of its (proper) positive divisors, including 1 but excluding itself. A divisor of a number is one which divides the number evenly (i.e., without a remainder). For example, consider number 6. Its divisors are 1, 2, 3, and 6. Since we do not include number itself, we only have 1, 2, and 3. Because the sum of these divisors of 6 is 6, i.e., 1 + 2...
A positive integer is a prime number if its only positive integer divisors are itself and 1. Write a program to determine whether or not a given integer is prime. The program should contain two functions: main: to ask the user for a positive integer and to print the result isPrime: to determine whether the user's input is prime by testing all possible divisors. This function should return two values: variable_1: a Boolean value indicating whether the number is prime...
Write a Python program to print all Perfect numbers between 1 to n. (Use any loop you want) Perfect number is a positive integer which is equal to the sum of its proper positive divisors. Proper divisors of 6 are 1, 2, 3. Sum of its proper divisors = 1 + 2 + 3 = 6. Hence 6 is a perfect number. *** proper divisor means the remainder will be 0 when divided by that number. Sample Input: n =...
In this assignment you are asked to write a Python program to determine all the prime numbers in between a range and store them in a list that will be printed when the range is searched. The user is prompted for two positive integer values as input, one is the start of the range and the other is the end of the range. If the user gives a negative value or enters a second number that is lower than the...
Please Write the task in c++ Task A perfect number is an integer that is equal to the sum of its divisors (where 1 is considered a divisor). For example, 6 is perfect because its divisors are 1, 2, and 3, and 1 + 2 + 3 is 6. Similarly, 28 is perfect because it equals 1 + 2 + 4 + 7 + 14. A quite good number is an integer whose badness—the size of the difference between the...
please help with python
EDIT: hmwk3q3 is just what the file is supposed to be named
Greatest Common Divisor Two integers A and B have the greatest common divisor which is the largest positive integer that divides A and B, evenly, without a remainder. One way to find the Greatest Common Divisor is to consider the prime factors for A = 372 and B = 84 as shown below. 372 = 22 * 3 31 84 = 22 +3 :...
IN PYHTON CODE
Question #3 Produce a function prime_factors.dict that has one integer variable n that is assumed to be greater than 1. The function will return a dictionary with keys the integers from 2 to n, inclusive, and with values the set of prime factors of each key. So, the command prime_factors.dict (8) will return the dictionary 2 123,3: 3),4 2),5 (53,6 2,3),7:7),8 {2)) Note that even though the prime number 2 appears twice in the prime fac- torization...
Write a program “hw4.c” that reads integer (less than or equal 100) from the keyboard and, on the output, writes the sum of the divisors of n (other than itself). For integers less than or equal to 1 it should print 0. For example, the input -3 0 1 4 5 6 12 should generate the output 0 0 0 3 1 6 16 Explanation of output: The input -3 is less than 1, output is 0. The input 0...
Write a C program named space_to_line.c that features a while loop that continuously reads input from the user one character at a time and then prints that character out. The exception is that if the user inputs a space character (‘ ‘), then a newline character (‘\n’) should be printed instead. This will format the output such that every word the user inputs is on its own line. Other than changing the spaces to newlines, the output should exactly match...