Difference between revisions of "ZCubes/Narcissistic Numbers"
Jump to navigation
Jump to search
(Created page with "==Narcissistic Numbers== <br/> Narcissistic numbers are numbers which you obtain when you take sum of the power of each digit to the length of the number, you get the number i...") |
(→Video) |
||
Line 6: | Line 6: | ||
{{#ev:youtube|mlfHvaU5j4Y|480|left|Narcissistic Numbers}} | {{#ev:youtube|mlfHvaU5j4Y|480|left|Narcissistic Numbers}} | ||
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/> | <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/> | ||
+ | |||
+ | ==Code-Narcissistic Numbers== | ||
+ | |||
+ | function narcissistic(n) | ||
+ | { | ||
+ | var d=DIGITS(n) | ||
+ | var k=d.length; | ||
+ | return(SUM(d.$(x=>x^k))==n) | ||
+ | } | ||
+ | narcissistic#; | ||
+ | nums=1..1000; | ||
+ | nums.pick(narcissistic(nums)) | ||
+ | |||
+ | //narcissistic(152) | ||
+ | |||
+ | //3^3+7^3+0^1 | ||
+ | |||
<<[[Main_Page | About ZCubes ]] | <<[[Main_Page | About ZCubes ]] |
Revision as of 03:21, 21 August 2020
Narcissistic Numbers
Narcissistic numbers are numbers which you obtain when you take sum of the power of each digit to the length of the number, you get the number itself. For example the number 153 is equal to 1^3+5^3+3^3. Can you find out other such numbers? In this video you can understand how you can use Z to easily find out such numbers.
Video
Code-Narcissistic Numbers
function narcissistic(n) {
var d=DIGITS(n) var k=d.length; return(SUM(d.$(x=>x^k))==n)
} narcissistic#; nums=1..1000; nums.pick(narcissistic(nums))
//narcissistic(152)
//3^3+7^3+0^1
<< About ZCubes
© Copyright 1996-2020, ZCubes, Inc.