Advertisement
Qpel

ED7.1.Rasti visus 3- lius sveikus skaičius, kurie yra lygūs

Jan 8th, 2018
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.25 KB | None | 0 0
  1. Rasti visus 3- lius sveikus skaičius, kurie yra lygūs savo skaitmenų sumos kvadratui.   
  2. sum=0
  3. for i in 100..999
  4.   n=i
  5.   while n>0
  6.     a=n%10
  7.     b=n/10
  8.     n=n/10
  9.     sum=sum+a
  10.   end
  11.   d=sum*sum
  12.   if i==d then
  13.     puts "#{i} "
  14.   end
  15.  
  16. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement