4
I have a doubt in C, I know check if a number is prime, however, almost cousin do not know.. as I do?
Follow the part of the code working! However, just checking if it is prime.. the almost prime does not run
// quasePrimos.c
//
//
// Created by Braynner Teixeira on 12/09/17.
// Copyright © 2017 Braynner Teixeira. All rights reserved.
//
#include <stdio.h>
int main(){
int num, i, controle=0;
printf("Informe um numero: ");
scanf("%d", &num);
if (num > 1)
{
// Dividir o numero informado por todos os numeros que estao entre ele e 1.
for (i = 1; i <= num; i++)
{
if (num % i == 0)
controle++;
}
if (controle == 2) {
printf("O numero %d e um numero primo!\n", num);
}
else if (controle == 2 && controle*controle == num) {
printf("O numero %d e quase primo!\n", num);
}else {
printf("O numero %d nao e um numero primo!\n", num);
}
}
else if (num == 1 ) printf("O numero nao é primo e nem quase primo!");
}
What is the concept of near prime number?
– Jefferson Quesado
Every integer greater than 1 has at least two positive divisors: itself and 1. The only exceptions are 0 and 1
– Jefferson Quesado
Jefferson Quesado, I give the number 15, and then his product: 3*5 is equal to himself.
– Braynner Teixeira
16 is almost cousin? I think not, can you confirm me? And 4 is also not almost cousin, check?
– Jefferson Quesado
Yeah, none of them are!
– Braynner Teixeira
Here says that 16 is almost cousin (to
k=4
) @Jeffersonquesado– bfavaretto
@bfavaretto perfect squares of compound numbers? Ok, so I need to study more
– Jefferson Quesado
That’s my question. Cruel...
– Braynner Teixeira
@Jefferson And me then? I’ve never heard of "almost" cousins so far. I don’t put my hand on the fire for what’s on Wikipedia, nor did I fully understand.
– bfavaretto
An almost prime number, or semi prime, is the product of two prime numbers. For example 4, 6, 9, etc... (22, 23, 3*3)
– Cleber Griff
As far as I know, it’s the product of two prime values
– Braynner Teixeira
@So Cleber would be what Wikipedia says limited to k=2?
– bfavaretto
@bfavaretto, is not limited. In this case, a "near prime" is the product of any prime number multiplied by any prime number.
– Cleber Griff
In the question it said the following: a number is almost prime if and only if it can be described as a product of two distinct cousins. Ex: 15 (= 5*3) is almost prime, 2 and 4 are not.
– Braynner Teixeira
Well, the concept of almost cousin in question is the 2-quasi-primo. So, @bfavaretto , is the concept of the Wiki in English given
k=2
. This talk ofk
is a generalization– Jefferson Quesado
Semi Primo is the same thing as Almost Primo? I thought not!! Semi Primo was the product of two cousins and Almost was of distinct cousins..
– Braynner Teixeira
@Braynnerteixeira according to the Wikipedia searches of people in this thread, no matter the numbers are different the same. And semi primo would be a specific case of quasi-primo
– Jefferson Quesado