All about
flooble
|
fun stuff
|
Get a free chatterbox
|
Free JavaScript
|
Avatars
perplexus
dot
info
Home
>
Algorithms
Single Line Expression (
Posted on 2008-01-27
)
Give a single line "C type" expression to evaluate (-1)
k
using only +,-,* and % operators.
See The Solution
Submitted by
Praneeth
Rating:
5.0000
(1 votes)
Comments: (
Back to comment list
| You must be logged in to post comments.
)
Puzzle Solution
Comment 6 of 6 |
Assuming that k is an integer, the required expression is:
(-1)^k = 1 - 2*(k%2)
Note: In advanced arithmetic, the above expression translates to,:
(-1)^k = 1 -2*{k (mod 2)}
Posted by
K Sengupta
on 2022-09-12 01:09:42
Please log in:
Login:
Password:
Remember me:
Sign up!
|
Forgot password
Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ
|
About This Site
Site Statistics
New Comments (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On
Chatterbox:
blackjack
flooble's webmaster puzzle
Copyright © 2002 - 2024 by
Animus Pactum Consulting
. All rights reserved.
Privacy Information