Posts

Showing posts from June, 2020

Weird numbers | Rosetta Code | #25

URL to the problem page:  http://rosettacode.org/wiki/Weird_numbers In number theory, a weird number is a natural number that is abundant but not semiperfect (and therefore not perfect either). In other words, the sum of the proper divisors of the number (divisors including 1 but not itself) is greater than the number itself (the number is abundant ), but no subset of those divisors sums to the number itself (the number is not semiperfect ). For example: 12 is not a weird number.     It is abundant; its proper divisors 1, 2, 3, 4, 6 sum to 16 (which is > 12),     but it is semiperfect, eg 6 + 4 + 2 == 12 . 70 is a weird number.     It is abundant; its proper divisors 1, 2, 5, 7, 10, 14, 35 sum to 74 (which is > 70),     and there is no subset of proper divisors that sum to 70 . Find and display, here on this page, the first 25 weird numbers. #include   <iostream> using   namespace ...

Fermat numbers | Rosetta Code | #24

URL to the problem page:  http://rosettacode.org/wiki/Fermat_numbers In mathematics, a Fermat number, named after Pierre de Fermat who first studied them , is a positive integer of the form F n  = 2 2^ n  + 1 where n is a non-negative integer. Despite the simplicity of generating Fermat numbers, they have some powerful mathematical properties and are extensively used in cryptography & pseudo-random number generation, and are often linked to other number theoric fields. As of this writing, (mid 2019), there are only five known prime Fermat numbers, the first five ( F 0  through F 4 ). Only the first twelve Fermat numbers have been completely factored, though many have been partially factored. Find and display here, on this page, the first 10 Fermat numbers - F 0  through F 9 . #include   <iostream> using   namespace   std ; int   power ( int   a ,  int   b ) {      int  re...

Smith numbers | Rosetta Code | #23

URL to the problem page:  https://rosettacode.org/wiki/Smith_numbers Smith numbers are numbers such that the sum of the decimal digits of the integers that make up that number is the same as the sum of the decimal digits of its prime factors excluding 1. By definition, all primes are excluded as they (naturally) satisfy this condition! Smith numbers are also known as joke numbers. Example Using the number 166 Find the prime factors of 166 which are: 2 x 83 Then, take those two prime factors and sum all their decimal digits: 2 + 8 + 3 which is 13 Then, take the decimal digits of 166 and add their decimal digits: 1 + 6 + 6 which is 13 Therefore, the number 166 is a Smith number. Write a program to find all Smith numbers below 10000. #include   <iostream> using   namespace   std ; int  n =  0 ,  factors [ 512 ] = {  0  }, multiply =  1 , thenumber =  0 ; int   power ...
My photo
Ercan Tomac
instagram.com/ercantomac