Difference between revisions of "ZCubes/Narcissistic Numbers"
Jump to navigation
Jump to search
(4 intermediate revisions by 2 users not shown) | |||
Line 4: | Line 4: | ||
==Video== | ==Video== | ||
<br/> | <br/> | ||
− | {{#ev:youtube| | + | {{#ev:youtube|g4QA9RzJj0M|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/> | ||
Line 17: | Line 17: | ||
narcissistic#; | narcissistic#; | ||
nums=1..1000; | nums=1..1000; | ||
− | nums.pick(narcissistic(nums)) | + | nums.pick(narcissistic(nums)) |
− | //narcissistic(152) | + | //narcissistic(152) |
− | //3^3+7^3+0^ | + | //3^3+7^3+0^3 |
− | |||
− | |||
<br/> | <br/> | ||
− | © Copyright 1996- | + | *[[Z3 | Z3 home]] |
+ | *[[Z^3 Language Documentation]] | ||
+ | *[[ZCubes_Videos | ZCubes Videos and Tutorials]] | ||
+ | *[[Main_Page | About ZCubes ]] | ||
+ | <br/> | ||
+ | <br/> | ||
+ | © Copyright 1996-2021, ZCubes, Inc. |
Latest revision as of 00:06, 11 March 2021
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^3
© Copyright 1996-2021, ZCubes, Inc.