Esempio n. 1
0
int is_prime(int n)
{
	if (is_trivial_prime(n))
		return 1;
	for (int d = 3; d < n; d += 2)
		if (is_divisible(n, d))
			return 0;
	return 1;
}
Esempio n. 2
0
int main(void)
{
    std::string s = "0123456789";
    uint64_t sm = 0;

    do {
        if (is_divisible(s))
            sm += std::stoull(s);
    } while (std::next_permutation(s.begin(), s.end()));

    std::cout << sm << "\n";
}
Esempio n. 3
0
int main()
{
    bool found = false;
    int i = 1;
    while(!found)
    {
      if(is_divisible(i))
        found = true;
      else
          i++;
    }
    std::cout << "Smallest number is " << i << "\n";
}
Esempio n. 4
0
File: modulus.c Progetto: pwener/RSA
/**
 *	[EN] This method discover the quantity of numbers n < x who not satisfies x|n
 *	[PT] Esse metodo descobre a quantitade de numeros n < x que nao satisfaz x|n
 *	@param input_number (x)
 *	@return phi (n)
 */
unsigned long long int euler_totient(unsigned long long int input_number)
{
	unsigned long long int associated_number = 1;
	unsigned long long int phi = 0;
	while(associated_number < input_number)
	{
		if(is_divisible(input_number, input_number) == FALSE)
		{
			phi++;
		}
		associated_number++;
	}
	return phi;
}
Esempio n. 5
0
int main() {

	int answer = 0;

	int num = 0;
	bool divided = false;
	while(divided == false) {
		num++;
		divided = is_divisible(num);
		answer = num;
	}

	cout << answer << endl;

}
Esempio n. 6
0
bool ConcurrentTableSharedStore
      ::APCMap<Key,T,HashCompare>
      ::getRandomAPCEntry(std::vector<EntryInfo>& entries) {
  assert(!this->empty());
#if TBB_VERSION_MAJOR >= 4
  auto current = this->range();
  for (auto rnd = rand(); rnd > 0 && current.is_divisible(); rnd >>= 1) {
    // Split the range 'current' into two halves: 'current' and 'otherHalf'.
    decltype(current) otherHalf(current, tbb::split());
    // Randomly choose which half to keep.
    if (rnd & 1) {
      current = otherHalf;
    }
  }
  auto apcPair = *current.begin();
  int64_t curr_time = time(nullptr);
  entries.push_back(makeEntryInfo(apcPair.first, &apcPair.second, curr_time));
  return true;
#else
  return false;
#endif
}
Esempio n. 7
0
File: modulus.c Progetto: pwener/RSA
/**
 *	[EN] This method check if the congruence is valid
 *	[PT] Esse metodo verifica se a congruencia e valida
 *	n|(a - r)
 *	@param a_number (a)
 *	@param b_number (r)
 *	@param modulus_number (n)
 *	@return TRUE if is congruent or False if is not congruent
 */
Boolean is_congruent(long long int a_number, long long int b_number, unsigned long long int modulus_number)
{
	Boolean is_congruent = is_divisible((a_number - b_number), modulus_number);
	return is_congruent;
}