Advertisement
Qpel

ED1.1 1. Duotas sveikas skaičius. Rasti skaitmenų, kurių kva

Jan 8th, 2018
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.24 KB | None | 0 0
  1. print "Iveskite skaiciu "
  2. sk=gets.to_i
  3. x=sk
  4. k=0
  5. suma=0
  6. while(x!=0)
  7.   s=x%10
  8.   kv=s*s
  9.   if(kv%2==0)
  10.     suma=suma+s
  11.     k=k+1
  12.   end
  13.   x=x/10
  14. end
  15. puts "Viso tokiu skaitmenu skaiciuje #{sk} yra: #{k}"
  16. puts "Siu skaitmenu suma: #{suma}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement