Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Make a C++ program Theorem: if n is composite (not prime), then n has an integer

ID: 3933922 • Letter: M

Question



Make a C++ program

Theorem: if n is composite (not prime), then n has an integer divisor n. Proof: Assume n is composite, then There is an integer a, 1 < a < n such that a is a factor of n; then There is an integer b > 1 such that n = ab; then Prove: Either a n or b n. This is the “then” part of the theorem. Proof of 4 by indirect proof: Assume the negation of 4): a > n and b > n; then ab > (n)2 ; then ab > n, contradicting 3) (where ab = n).

Make a C++ program

Theorem: if n is composite (not prime), then n has an integer divisor n. Proof: Assume n is composite, then There is an integer a, 1 < a < n such that a is a factor of n; then There is an integer b > 1 such that n = ab; then Prove: Either a n or b n. This is the “then” part of the theorem. Proof of 4 by indirect proof: Assume the negation of 4): a > n and b > n; then ab > (n)2 ; then ab > n, contradicting 3) (where ab = n).

Make a C++ program

Theorem: if n is composite (not prime), then n has an integer divisor n. Proof: Assume n is composite, then There is an integer a, 1 < a < n such that a is a factor of n; then There is an integer b > 1 such that n = ab; then Prove: Either a n or b n. This is the “then” part of the theorem. Proof of 4 by indirect proof: Assume the negation of 4): a > n and b > n; then ab > (n)2 ; then ab > n, contradicting 3) (where ab = n).

Explanation / Answer

**********************Theorem: if n is composite (not prime), then n has an integer divisor n.*****************

#include <iostream>
#include<math.h>
using namespace std;


int main()
{
int a, b, n, i, j, factor;
int m=0;
cout<<"Enter number n: ";
cin>>n;
for(a = 2; a <n; a++){
for(b = 2; b <n; b++){

if(n%a == 0){
  
factor=a;
}
if (n == a * a){//if n=a*a then n>a
m=a; // if n is perfect square of a
}
if(n ==a*b){ //if n=a*b
  
i=a;
j=b;
  
}
  
  
}
  
}
if(m !=0){ //if number n is perfect square
  
if(m>=i){//for either a<= root of n

cout<<"n has integer divisor <= root of n : ";
}
if(m >=j){//for or b<= root of n
  
cout<<"n has integer divisor <= root of n : ";
  
}
}

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote