This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
k_plus_sigma_k_is_perfect.py | |
edited and modified by MFH | |
forked from D.Radcliffe | |
Problem: | |
The number 10 has a special property. When 10 is added to the sum | |
of its divisors, the result is 28, which is a perfect number. | |
10 + sigma(10) = 10 + 1 + 2 + 5 + 10 = 28 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" isprime.py | |
May / June 2022 by M. F. Hasler | |
SYNOPSIS: very simple implementation of basic Number Theory functions: | |
isprime(n): return True or False according to whether n is prime or not | |
nextprime(n, i=1): return the i-th prime > n (i.e., >= n + 1). | |
prevprime(n, i=1): return the i-th prime < n or 0 if n < prime(n). | |
primes(n=math.inf, start=2, end=math.inf): return a generator | |
producing at most n primes in [start, end). | |
isprimepower(n): return True if n is prime, or |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// findNextPrime.cpp - return the next larger prime number | |
// (input taken from command line args or from stdin) | |
#include <iostream> | |
int findNextPrime(int n); // given a number n, find the next larger prime number above n | |
bool isPrime(int n); // given a number n, determine whether it is prime | |
int main(int argc, char**argv) | |
{ | |
int input; |