Question

I got a C++ problem.

Here i provide the code snapshot...

Here is the output snapshots...

Here are the extra outputs...

Here is the code...

#include <iostream>
using namespace std;
bool prime(int n)
{
int c=0;
for(int i=2;i<n/2;i++)
{
if((i%2)==0)
{ c++;
}

}
if(c==0 && n!=1)
return true;
else
return false;
}
int main()
{
int input,k;
cin>>input; //Takes input from user....
int count=0,max=-1;
for(int i=1;i<=input;i++)
{
count=0;
for(int j=1;j<=i;j++)
{
if(i%j==0)
{
count++; //count the numbers of divisors
}
}
if(max < count) //takes the maximum number of divisors
{ if(!prime(i)) //and the number is antiprime
{
max=count;
k=i; //store the number who have greatest number of divisors
}
//cout << "k value is"<<max;
}
}
cout << k<<endl;
//cout << max;
return 0;
}

If you have any doubts please COMMENT

#### Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
• ### 2. Let n be a positive integer. Denote the number of positive integers less than n and rela- tive...

number thoery just need 2 answered 2. Let n be a positive integer. Denote the number of positive integers less than n and rela- tively prime to n by p(n). Let a, b be positive integers such that ged(a,n) god(b,n)-1 Consider the set s, = {(a), (ba), (ba), ) (see Prollern 1). Let s-A]. Show that slp(n). 1. Let a, b, c, and n be positive integers such that gcd(a, n) = gcd(b, n) = gcd(c, n) = 1 If...

• ### for each positive integer m, let v(m) denote the number of divisors of m. define the function F(n) =∑ v (d)                                    dIn where the sum is over all positive divisors d of n p...

for each positive integer m, let v(m) denote the number of divisors of m. define the function F(n) =∑ v (d)                                    dIn where the sum is over all positive divisors d of n prove that function F(n) is multiplicative

• ### Q18 12 Points For any positive integer n, let bn denote the number of n-digit positive...

Q18 12 Points For any positive integer n, let bn denote the number of n-digit positive integers whose digits are all 1 or 2, and have no two consecutive digits of 1. For example, for n - 3, 121 is one such integer, but 211 is not, since it has two consecutive 1 's at the end. Find a recursive formula for the sequence {bn}. You have to fully prove your answer.

• ### 12 ) - 2. Let p(n) denote the number ofdstinct prime divisors ofn. For example, p( p(24)-2 and p(60) 3. Let q(n)an, where a is fixed and show that qn) is multiplicative, but not completely mul...

12 ) - 2. Let p(n) denote the number ofdstinct prime divisors ofn. For example, p( p(24)-2 and p(60) 3. Let q(n)an, where a is fixed and show that qn) is multiplicative, but not completely multiplicative. 12 ) - 2. Let p(n) denote the number ofdstinct prime divisors ofn. For example, p( p(24)-2 and p(60) 3. Let q(n)an, where a is fixed and show that qn) is multiplicative, but not completely multiplicative.

• ### Need help programing this in C. rinteivsors Print the proper divisors of an integer value The...

Need help programing this in C. rinteivsors Print the proper divisors of an integer value The program should read a single integer input value, which you can assume will be positive. It should then print a single line of output with all of the proper divisors of the input value in order from least to greatest. A proper divisor d of an integer n is an integer that evenly divides n: i.e., nld is an integer For example, if the...

• ### Write a program “hw4.c” that reads integer (less than or equal 100) from the keyboard and,...

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...

• ### 12. Let D = {2E C | 너く1} denote the open unit disc and let f : D → C be a holomorphic function. Suppose that for any integer n>1 we have that f(1/n)-1/n3. Show that f(z)3. 12. Let D = {2E C...

12. Let D = {2E C | 너く1} denote the open unit disc and let f : D → C be a holomorphic function. Suppose that for any integer n>1 we have that f(1/n)-1/n3. Show that f(z)3. 12. Let D = {2E C | 너く1} denote the open unit disc and let f : D → C be a holomorphic function. Suppose that for any integer n>1 we have that f(1/n)-1/n3. Show that f(z)3.

• ### Write a C program that takes a positive integer n as input and prints all the...

Write a C program that takes a positive integer n as input and prints all the prime numbers from 1 to n. Sample Input/Output 1: Enter your n: 20 Prime number(s) from 1 to 20 : 2 3 5 7 11 13 17 19 Sample Input/Output 2: Enter your n:2Prime number(s) from 1 to 2 : 2

• ### 9% of people in the U.S. have type B-positive blood. Let N denote the number of...

9% of people in the U.S. have type B-positive blood. Let N denote the number of people we must sample in order to find one having that blood type. Determine P(N < 12). a) .484    b) .526 c) .646 d) .733 e) .824

• ### Please paste your code and a screenshot of your output! 1. An integer n is divisible...

Please paste your code and a screenshot of your output! 1. An integer n is divisible by 9 if the sum of its digits is divisible by 9. Develop a program to determine whether or not the following numbers are divisible by 9: n= 154368 n 621594 n-123456 2. A number is said to be perfect if the sum of its divisors (except for itself) is equal to itself. For example, 6 is a perfect number because the sum of...